Browse Source

新增调货单

chenrui 2 năm trước cách đây
mục cha
commit
3b45529b74

+ 179 - 123
src/views/numsGoodsShelves/recallManagement/addRecallBillModal.vue

@@ -4,7 +4,7 @@
     class="shelfSet-basicInfo-modal"
     :footer="null"
     :maskClosable="false"
-    title="新增回调单--[数字货架]名吃环境啥的技术附件"
+    :title="recallBillInfo.shelfName"
     v-model="isShow"
     @cancel="isShow = false"
     width="60%">
@@ -12,40 +12,39 @@
       <a-form-model
         id="shelfSet-basicInfo-form"
         ref="ruleForm"
-        :model="form"
-        :rules="rules"
+        :model="queryParam"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol">
-        <a-row :gutter="16">
-          <a-col :span="8">
-            <a-form-model-item label="产品编码" prop="shelfName">
-              <a-input allowClear placeholder="请输入产品编码" v-model.tirm="form.productCode"/>
+        <a-row :gutter="10">
+          <a-col :md="8" :sm="24">
+            <a-form-model-item label="产品编码">
+              <a-input allowClear placeholder="请输入产品编码" v-model.tirm="queryParam.productCode"/>
             </a-form-model-item>
           </a-col>
-          <a-col :span="8">
+          <a-col :md="8" :sm="24">
             <a-form-item label="产品名称">
-              <a-input allowClear placeholder="请输入产品名称" v-model.tirm="form.productName"/>
+              <a-input allowClear placeholder="请输入产品名称" v-model.tirm="queryParam.productName"/>
             </a-form-item>
           </a-col>
-          <a-col :span="8">
+          <a-col :md="8" :sm="24">
             <a-form-model-item label="滞销天数">
               <a-input-group>
                 <a-row>
-                  <a-col :span="11">
+                  <a-col :md="11" :sm="24">
                     <a-input-number
                       id="shelfMonitoringList-minUnsalableDays"
-                      v-model="form.minUnsalableDays"
+                      v-model="queryParam.unsalableDaysBegin"
                       :precision="0"
                       :min="0"
                       :max="999999"
                       placeholder="起始天数"
                       style="width: 100%;display: inline-block;" />
                   </a-col>
-                  <a-col :span="2"><span style="display: block;text-align: center;line-height: 32px;">至</span></a-col>
-                  <a-col :span="11">
+                  <a-col :md="2" :sm="24"><span style="display: block;text-align: center;line-height: 32px;">至</span></a-col>
+                  <a-col :md="11" :sm="24">
                     <a-input-number
                       id="shelfMonitoringList-maxUnsalableDays"
-                      v-model="form.maxUnsalableDays"
+                      v-model="queryParam.unsalableDaysEnd"
                       :precision="0"
                       :min="0"
                       :max="999999"
@@ -57,32 +56,51 @@
             </a-form-model-item>
           </a-col>
           <a-col :span="24" style="text-align: right;padding-right: 30px;">
-            <a-button type="primary" @click="getSumByType" :disabled="disabled" id="outboundOrderList-refresh" >查询</a-button>
-            <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="outboundOrderList-reset">重置</a-button>
+            <a-button type="primary" @click="handleSearch" id="outboundOrderList-refresh" >查询</a-button>
+            <a-button style="margin-left: 8px" @click="resetSearchForm" id="outboundOrderList-reset">重置</a-button>
           </a-col>
         </a-row>
       </a-form-model>
       <div class="tableCon">
         <div style="margin-bottom: 16px">
-          <a-button type="primary" :disabled="!hasSelected" :loading="loading" @click="start">
+          <a-button type="primary" :disabled="!hasSelected" @click="handleSave">
             新增调回单
           </a-button>
           <span class="tableSpan">
             <template v-if="hasSelected">
-              已选<span>{{ selectedRowKeys.length }}</span>款产品,共<span>10</span>件
+              已选<span>{{ selectedRowKeys.length }}</span>款产品,共<span>{{ dataList.length }}</span>件
             </template>
           </span>
           <span>
-            <a-checkbox @change="onChange" size="small">
+            <a-checkbox @change="isShowChooseList" size="small">
               仅显示已选产品
             </a-checkbox>
           </span>
         </div>
         <a-table
-          :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
+          class="sTable"
+          ref="recallBillTable"
+          size="small"
+          :rowKey="record => record.id"
           :columns="columns"
-          :data-source="data"
-        >
+          :dataSource="dataList"
+          :scroll="{ y: 200 }"
+          :pagination="false"
+          bordered
+          :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }">
+          <!-- 调回数量 -->
+          <template slot="confirmQty" slot-scope="text, record">
+            <a-input-number
+              size="small"
+              id="shelfMonitoring-add-confirmQty"
+              v-model="record.confirmQty"
+              :precision="0"
+              :min="0"
+              :max="record.qty"
+              placeholder="请输入"
+              :style="{ width: '100%', color: record.confirmQty == 0 ? 'red' : '' }"
+            />
+          </template>
         </a-table>
       </div>
     </a-spin>
@@ -91,13 +109,10 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { VSelect } from '@/components'
-import custList from '@/views/common/custList.vue'
-import shelfSList from '@/views/common/shelfList'
-import { shelfSave } from '@/api/shelf'
+import { shelfControlList } from '@/api/shelf'
+import { shelfRecallSave } from '@/api/shelfRecall'
 export default {
-  name: 'ShelfSetRecallBillModal',
-  components: { VSelect, custList, shelfSList },
+  name: 'AddRecallBillModal',
   mixins: [commonMixin],
   props: {
     openModal: {
@@ -105,15 +120,11 @@ export default {
       type: Boolean,
       default: false
     },
-    nowData: {
+    recallBillInfo: {
       type: Object,
       default: () => {
         return {}
       }
-    },
-    type: {
-      type: [String, Number],
-      default: '1'
     }
   },
   data () {
@@ -124,96 +135,151 @@ export default {
         labelCol: { span: 5 },
         wrapperCol: { span: 17 }
       },
-      form: {
-
+      queryParam: { //  查询条件
+        shelfSn: '',
+        productCode: undefined,
+        productName: undefined,
+        unsalableDaysBegin: undefined,
+        unsalableDaysEnd: undefined
       },
       columns: [
         { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
-        { title: '货位号', dataIndex: 'no', width: '15%', align: 'center' },
-        { title: '产品编码', dataIndex: 'product.code', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'product.name', width: '30%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '最大库容', dataIndex: 'qty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text) : '--' } },
-        { title: '补货在途', dataIndex: 'confirmQty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text) : '--' } },
-        { title: '调回在途', dataIndex: 'product.unit', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '货架库存', dataIndex: 'confirmQty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text) : '--' } },
-        { title: '单位', dataIndex: 'product.unit', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '滞销天数', dataIndex: 'confirmQty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? toThousands(text) : '--' } },
-        { title: '调回数量', width: '15%', align: 'left', scopedSlots: { customRender: 'num' } }
+        { title: '货位号', dataIndex: 'shelfPlaceCode', width: '15%', align: 'center' },
+        { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '30%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '最大库容', dataIndex: 'maxQty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
+        { title: '补货在途', dataIndex: 'replenishBillQty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
+        { title: '调回在途', dataIndex: 'recallBillQty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
+        { title: '货架库存', dataIndex: 'qty', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
+        { title: '单位', dataIndex: 'productUnit', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '滞销天数', dataIndex: 'unsalableDays', width: '15%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
+        { title: '调回数量', width: '20%', align: 'left', scopedSlots: { customRender: 'confirmQty' } }
       ],
-      selectedRowKeys: [], // Check here to configure the default column
-      loading: false,
-      hasSelected: true,
-      rules: {
-        shelfName: [{ required: true, message: '请选择货架名称', trigger: 'change' }]
-      },
-      showRecallBill: false
+      selectedRowKeys: [], // 选中表格id
+      hasSelected: false, // 控制选择按钮
+      dataList: [],
+      chooseList: []
     }
   },
   methods: {
-    start () {
-      this.loading = true
-      // ajax request after empty completing
-      setTimeout(() => {
-        this.loading = false
-        this.selectedRowKeys = []
-      }, 1000)
+    getLoadData (ajaxData) { // 获取列表
+      this.spinning = true
+      if (!this.checkValueRange()) {
+        this.spinning = false
+        return
+      }
+      shelfControlList(ajaxData).then(res => {
+        if (res.status == 200) {
+          for (var i = 0; i < res.data.length; i++) {
+            res.data[i].no = i + 1
+            res.data[i].confirmQty = res.data[i].qty
+          }
+          this.dataList = res.data
+          this.spinning = false
+        } else {
+          this.spinning = false
+        }
+      })
     },
-    onSelectChange (selectedRowKeys) {
-      console.log('selectedRowKeys changed: ', selectedRowKeys)
+    onSelectChange (selectedRowKeys, selectedRows) { // 获取选中列表
+      if (selectedRowKeys.length > 0) {
+        this.hasSelected = true
+      } else {
+        this.hasSelected = false
+      }
       this.selectedRowKeys = selectedRowKeys
+      this.chooseList = selectedRows
     },
-    shelfChange (v, row) {
-      this.shelfName = row ? row.shelfName : ''
-    },
-    // 下一步 保存货架信息
-    handlerNextStep () {
-      this.showRecallBill = true
-    },
-    // 客户 change
-    custChange (obj, row) {
-      this.form.customerSn = row && row.customerSn || undefined
-    },
-    //  保存
+    //  确定新增回调单
     handleSave () {
       const _this = this
-      this.$refs.ruleForm.validate(valid => {
-        if (valid) {
-          const form = JSON.parse(JSON.stringify(_this.form))
-          form.shelfSn = _this.nowData && _this.nowData.shelfSn
-          _this.spinning = true
-          shelfSave(form).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              setTimeout(() => {
-                _this.isShow = false
-                _this.$emit('ok', res.data)
-                _this.spinning = false
-              }, 100)
-              // 更新价格显示
-              // updateShelfPriceShow({
-              //   shelfSn: form.shelfSn,
-              //   paramValue: form.showPrice
-              // }).then(ret => {
-              //   if (ret.status == 200) {
-              //     _this.$message.success(ret.message)
-              //     setTimeout(() => {
-              //       _this.isShow = false
-              //       _this.$emit('ok', res.data)
-              //       _this.spinning = false
-              //     }, 100)
-              //   } else {
-              //     _this.spinning = false
-              //   }
-              // })
-            } else {
-              _this.spinning = false
-            }
+      _this.spinning = true
+      const arr = []
+      const arrInd = []
+      this.chooseList.forEach((item, index) => {
+        if (item.confirmQty) {
+          arr.push({
+            shelfSn: item.shelfSn,
+            shelfPlaceSn: item.shelfPlaceSn,
+            shelfPlaceCode: item.shelfPlaceCode,
+            productSn: item.productSn,
+            productCode: item.productCode,
+            productName: item.productName,
+            qty: item.confirmQty
           })
         } else {
-          console.log('error submit!!')
-          return false
+          arrInd.push(index + 1)
         }
       })
+      if (arrInd.length > 0) {
+        this.$message.warning('调回数量不能为空或0,请移除后提交')
+        return
+      }
+      const params = {
+        shelfSn: this.recallBillInfo.shelfSn,
+        detailList: arr
+      }
+      shelfRecallSave(params).then(res => {
+        _this.spinning = false
+        if (res.status == 200) {
+          _this.$emit('ok')
+          _this.isShow = false
+          _this.hasSelected = false
+          _this.selectedRowKeys = [] // 清空选中内容
+          _this.$message.success('保存并确认成功')
+        }
+      })
+    },
+    isShowChooseList (e) {
+      if (e.target.checked) {
+        this.dataList = this.chooseList
+      } else {
+        this.getLoadData(this.queryParam)
+      }
+    },
+    // 查询
+    handleSearch () {
+      const ajaxData = this.queryParam
+      this.getLoadData(ajaxData)
+    },
+    // 重置
+    resetSearchForm () {
+      const obj = { //  查询条件
+        shelfSn: this.recallBillInfo.shelfSn,
+        productCode: undefined,
+        productName: undefined,
+        unsalableDaysBegin: undefined,
+        unsalableDaysEnd: undefined
+      }
+      this.queryParam = obj
+      this.getLoadData(obj)
+    },
+    // 校验滞销天数数值范围
+    checkValueRange () {
+      const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
+      const isOEmpty = this.queryParam.unsalableDaysBegin === ''
+      const isOZero = this.queryParam.unsalableDaysBegin === 0
+      const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
+      const isTEmpty = this.queryParam.unsalableDaysEnd === ''
+      const isTZero = this.queryParam.unsalableDaysEnd === 0
+      //  第一个为空(可为null可为空字符)第二个不为空
+      //  第一个不为空第二个为空(可为null可为空字符)
+      //  第一个大于第二个
+      if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
+        this.$message.info('请输入正确的滞销天数查询范围!')
+        return false
+      }
+      if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
+        this.$message.info('请输入正确的滞销天数查询范围!')
+        return false
+      }
+      if (this.queryParam.unsalableDaysBegin > this.queryParam.unsalableDaysEnd) {
+        this.$message.info('请输入正确的滞销天数查询范围!')
+        return false
+      }
+      this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
+      this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
+      return true
     }
   },
   watch: {
@@ -228,21 +294,11 @@ export default {
         this.$refs.ruleForm.resetFields()
         // this.$refs.custList.resetForm()
       } else {
-        // const _this = this
-        // this.$nextTick(() => {
-        //   _this.form.shelfName = _this.nowData.shelfName
-        //   _this.form.showPrice = _this.nowData.showPrice
-        //   const custome = _this.nowData.customerEntity
-        //   if (custome) {
-        //     _this.form.customerSn = custome.customerSn || ''
-        //     _this.$refs.custList.fetchUser(custome.customerName || '')
-        //     _this.$refs.custList.dealerName = {
-        //       key: custome.customerSn,
-        //       label: custome.customerName,
-        //       row: _this.nowData
-        //     }
-        //   }
-        // })
+        if (this.recallBillInfo && this.recallBillInfo.shelfSn) {
+          this.queryParam.shelfSn = this.recallBillInfo.shelfSn
+          const ajaxData = { shelfSn: this.recallBillInfo.shelfSn }
+          this.getLoadData(ajaxData)
+        }
       }
     }
   }

+ 19 - 51
src/views/numsGoodsShelves/recallManagement/basicInfoModal.vue

@@ -16,8 +16,8 @@
         :rules="rules"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol">
-        <a-form-model-item label="货架名称" prop="shelfName">
-          <shelfSList v-model="form.shelfName" @change="shelfChange"></shelfSList>
+        <a-form-model-item label="货架名称" prop="shelfSn">
+          <shelfSList v-model="form.shelfSn" @change="shelfChange"></shelfSList>
         </a-form-model-item>
       </a-form-model>
       <div class="btn-cont">
@@ -26,7 +26,7 @@
       </div>
     </a-spin>
     <!-- 新增回调单(实现新增) -->
-    <add-recall-bill-modal :openModal="showRecallBill" @close="showRecallBill=false"></add-recall-bill-modal>
+    <add-recall-bill-modal :recallBillInfo="detailObj" :openModal="showRecallBill" @ok="handleInfoOk" @close="showRecallBill=false"></add-recall-bill-modal>
   </a-modal>
 </template>
 
@@ -35,15 +35,13 @@ import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import custList from '@/views/common/custList.vue'
 import shelfSList from '@/views/common/shelfList'
-import { shelfSave } from '@/api/shelf'
 import addRecallBillModal from './addRecallBillModal.vue'
 export default {
   name: 'ShelfSetBasicInfoModal',
   components: { VSelect, custList, shelfSList, addRecallBillModal },
   mixins: [commonMixin],
   props: {
-    openModal: {
-      //  弹框显示状态
+    openModal: { //  弹框显示状态
       type: Boolean,
       default: false
     },
@@ -67,67 +65,38 @@ export default {
         wrapperCol: { span: 17 }
       },
       form: {
-        shelfName: ''
+        shelfSn: undefined
       },
       rules: {
-        shelfName: [{ required: true, message: '请选择货架名称', trigger: 'change' }]
+        shelfSn: [{ required: true, message: '请选择货架名称', trigger: 'change' }]
       },
-      showRecallBill: false
+      showRecallBill: false, // 显示选择货架弹窗
+      detailObj: {
+        shelfName: '',
+        shelfSn: ''
+      }
     }
   },
   methods: {
     shelfChange (v, row) {
-      this.shelfName = row ? row.shelfName : ''
+      this.detailObj.shelfName = row ? row.shelfName : ''
     },
     // 下一步 保存货架信息
     handlerNextStep () {
-      this.showRecallBill = true
-    },
-    // 客户 change
-    custChange (obj, row) {
-      this.form.customerSn = row && row.customerSn || undefined
-    },
-    //  保存
-    handleSave () {
-      const _this = this
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          const form = JSON.parse(JSON.stringify(_this.form))
-          form.shelfSn = _this.nowData && _this.nowData.shelfSn
-          _this.spinning = true
-          shelfSave(form).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              setTimeout(() => {
-                _this.isShow = false
-                _this.$emit('ok', res.data)
-                _this.spinning = false
-              }, 100)
-              // 更新价格显示
-              // updateShelfPriceShow({
-              //   shelfSn: form.shelfSn,
-              //   paramValue: form.showPrice
-              // }).then(ret => {
-              //   if (ret.status == 200) {
-              //     _this.$message.success(ret.message)
-              //     setTimeout(() => {
-              //       _this.isShow = false
-              //       _this.$emit('ok', res.data)
-              //       _this.spinning = false
-              //     }, 100)
-              //   } else {
-              //     _this.spinning = false
-              //   }
-              // })
-            } else {
-              _this.spinning = false
-            }
-          })
+          this.detailObj.shelfSn = this.form.shelfSn
+          this.showRecallBill = true
         } else {
           console.log('error submit!!')
           return false
         }
       })
+    },
+    // 新增调货单成功
+    handleInfoOk () {
+      this.$emit('ok')
+      this.isShow = false
     }
   },
   watch: {
@@ -140,7 +109,6 @@ export default {
       if (!newValue) {
         this.$emit('close')
         this.$refs.ruleForm.resetFields()
-        // this.$refs.custList.resetForm()
       } else {
         // const _this = this
         // this.$nextTick(() => {

+ 2 - 2
src/views/numsGoodsShelves/recallManagement/list.vue

@@ -344,8 +344,8 @@ export default {
       this.detailContent = con
       this.showDetail = true
     },
-    handleInfoOk () {
-
+    handleInfoOk (e) {
+      this.$refs.table.refresh()
     }
   },
   mounted () {