lilei 2 vuotta sitten
vanhempi
commit
f9f2b5849f

+ 1 - 1
public/version.json

@@ -1,5 +1,5 @@
 {
   "message": "发现有新版本发布,确定更新系统?",
   "vendorJsVersion": "",
-  "version": 1660871779116
+  "version": 1660990726896
 }

+ 18 - 1
src/api/shelf.js

@@ -109,8 +109,25 @@ export const shelfPutOutDetailList = (params) => {
 // 修改完成标识
 export const modifFinishFlag = (params) => {
   return axios({
-    url: `/shelf/modifFinishFlag `,
+    url: `/shelf/modifFinishFlag`,
     data: params,
     method: 'post'
   })
 }
+
+// 新增货位
+export const addPlaceAndProduct = (params) => {
+  return axios({
+    url: `/shelf/placeAndProduct/save`,
+    data: params,
+    method: 'post'
+  })
+}
+// 删除货位
+export const delShelfPlaceSn = (params) => {
+  return axios({
+    url: `/shelf/place/deleteBySn/${params.shelfPlaceSn}`,
+    data: params,
+    method: 'post'
+  })
+}

+ 175 - 84
src/views/numsGoodsShelves/shelfSet/addHWModal.vue

@@ -1,143 +1,234 @@
 <template>
-  <div>
-    <a-modal
-      centered
-      wrapClassName="addHWModal-modal"
-      :footer="null"
-      :maskClosable="false"
-      :title="textTitle"
-      v-model="isshow"
-      @cancle="isshow=false"
-      :width="500">
-      <a-spin :spinning="spinning" tip="Loading...">
-        <a-form-model
-          id="addHWModal-form"
-          ref="ruleForm"
-          :model="form"
-          :rules="rules"
-        >
-          <a-row :gutter="20">
-            <a-col :span="24">
-              <a-form-model-item label="货位号" prop="shelfPlaceCode" :label-col="{span: 5}" :wrapper-col="{span: 18}">
-                <a-input id="addHWModal-shelfPlaceCode" v-model.trim="form.shelfPlaceCode" allowClear placeholder="请输入货位号"/>
-              </a-form-model-item>
+  <a-modal
+    centered
+    class="shelfSet-newHw-modal"
+    :footer="null"
+    :maskClosable="false"
+    :title="modalTit"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="600">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="shelfSet-newHw-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol">
+        <a-form-model-item label="货架名称">{{ nowData&&nowData.shelfName || '--' }}</a-form-model-item>
+        <a-form-model-item label="货位号" prop="shelfPlaceCode">
+          <a-input v-model="form.shelfPlaceCode" placeholder="请输入货位号"></a-input>
+        </a-form-model-item>
+        <a-form-model-item label="绑定产品" v-if="type=='add'">
+          <productJqList ref="productJqList" :params="{customerSn:nowData&&nowData.customerSn}" @change="productJqChange"></productJqList>
+        </a-form-model-item>
+        <a-form-model-item label="产品名称" v-if="form.productSn">{{ productName || '--' }}</a-form-model-item>
+        <a-form-model-item v-if="form.productSn" label="销售价" prop="price">
+          <a-row>
+            <a-col :span="20">
+              <a-input-number
+                id="shelfSet-newHw-price"
+                v-model="form.price"
+                :precision="2"
+                :min="0.01"
+                :max="999999"
+                placeholder="请输入正数(最多允许两位小数)"
+                suffix="元"
+                style="width: 100%;display: inline-block;" />
             </a-col>
+            <a-col :span="4"><span style="margin-left: 10px;">元</span></a-col>
           </a-row>
-          <a-form-model-item :label-col="{span: 0}" :wrapper-col="{span: 24}" style="text-align: center;">
-            <a-button type="primary" @click="handleSubmit()" :style="{ marginRight: '8px' }" id="addHWModal-handleSubmit">保存</a-button>
-            <a-button :style="{ marginLeft: '8px' }" @click="isshow=false" id="addHWModal-close">取消</a-button>
-          </a-form-model-item>
-        </a-form-model>
-      </a-spin>
-    </a-modal>
-  </div>
+        </a-form-model-item>
+        <a-form-model-item v-if="form.productSn" label="结算价" prop="cost">
+          <a-row>
+            <a-col :span="20">
+              <a-input-number
+                id="shelfSet-newHw-cost"
+                v-model="form.cost"
+                :precision="2"
+                :min="0"
+                :max="999999"
+                placeholder="请输入正数(最多允许两位小数)"
+                suffix="元"
+                style="width: 100%;display: inline-block;" />
+            </a-col>
+            <a-col :span="4"><span style="margin-left: 10px;">元</span></a-col>
+          </a-row>
+        </a-form-model-item>
+        <a-form-model-item v-if="form.productSn" label="最大库容" prop="maxQty">
+          <a-input-number
+            id="shelfSet-newHw-maxQty"
+            v-model="form.maxQty"
+            :precision="0"
+            :min="0"
+            :max="999999"
+            placeholder="请输入最大库容(正整数或0)"
+            suffix="元"
+            style="width: 100%;display: inline-block;" />
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button type="primary" id="shelfSet-newHw-modal-save" @click="handleSave">保存</a-button>
+        <a-button id="shelfSet-newHw-modal-back" @click="isShow=false" style="margin-left: 15px;">取消</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
 </template>
 
 <script>
-import { saveHw, shelfHWDetail } from '@/api/shelf.js'
+import { commonMixin } from '@/utils/mixin'
+import { VSelect } from '@/components'
+import productJqList from '@/views/common/productJqList.vue'
+import { addPlaceAndProduct } from '@/api/shelf'
 export default {
-  name: 'AddHWModal',
+  name: 'AddHwModal',
+  components: { VSelect, productJqList },
+  mixins: [commonMixin],
   props: {
-    openHWModal: {
+    openModal: { //  弹框显示状态
       type: Boolean,
       default: false
     },
-    shelfSn: {
-      type: [String, Number],
+    type: {
+      type: String,
       default: ''
     },
     nowData: {
       type: Object,
-      default: function () {
+      default: () => {
         return {}
       }
     }
   },
-
   data () {
     return {
       spinning: false,
-      isshow: this.openHWModal,
-      textTitle: '新增货位',
-      roleList: [],
-      pageInfo: null,
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 4 },
+        wrapperCol: { span: 18 }
+      },
       form: {
-        shelfPlaceCode: '' // 货位号
+        shelfPlaceCode: '',
+        productSn: undefined,
+        productCode: undefined,
+        price: '',
+        cost: '',
+        maxQty: ''
       },
       rules: {
-        shelfPlaceCode: [ { required: true, message: '请输入货位号', trigger: 'blur' }, { pattern: '^[^\u4e00-\u9fa5]{0,}$', message: '货位号不支持汉字' }]
+        shelfPlaceCode: [{ required: true, message: '请输入货位号', trigger: 'blur' }],
+        price: [{ required: true, message: '请输入销售价', trigger: 'blur' }],
+        cost: [{ required: true, message: '请输入结算价', trigger: 'blur' }],
+        maxQty: [{ required: true, message: '请输入最大库容', trigger: 'blur' }]
+      },
+      productName: ''
+    }
+  },
+  computed: {
+    modalTit () {
+      let title = ''
+      if (this.type == 'edit') {
+        title = '编辑货位'
+      } else if (this.type == 'add') {
+        title = '新增货位'
       }
+      return title
     }
   },
   methods: {
-    // 过滤空格
-    filterEmpty () {
-      let str = this.form.name
-      str = str.replace(/\ +/g, '')
-      str = str.replace(/[ ]/g, '')
-      str = str.replace(/[\r\n]/g, '')
-      this.form.name = str
+    // 产品 change
+    productJqChange (obj) {
+      this.form.productSn = obj.key || undefined
+      this.form.productCode = obj && obj.row && obj.row.code || ''
+      this.form.price = obj && obj.row && obj.row.price || ''
+      this.form.cost = obj && obj.row && obj.row.cost || ''
+      this.productName = obj && obj.row && obj.row.name || ''
     },
-    // 查询货位详情
-    getShelfHWDetail () {
-      this.spinning = true
-      shelfHWDetail({ shelfPlaceSn: this.nowData.shelfPlaceSn }).then(res => {
-        if (res.status == 200) {
-          this.form = Object.assign({}, res.data)
-        }
-        this.spinning = false
-      })
-    },
-    // 保存提交
-    handleSubmit () {
+    //  保存
+    handleSave () {
       const _this = this
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          const params = JSON.parse(JSON.stringify(_this.form))
-          params.shelfSn = _this.shelfSn ? _this.shelfSn : null
-          console.log(params.id, params.shelfSn, '------------编辑新增')
+          const params = {}
+          const form = JSON.parse(JSON.stringify(_this.form))
+          params.shelfSn = _this.nowData && _this.nowData.shelfSn
+          params.shelfPlaceCode = form.shelfPlaceCode
+          if (this.type == 'edit') {
+            params.id = this.nowData.id
+          }
+          // 绑定了产品
+          if (form.productSn) {
+            params.shelfProductApiEntity = {
+              productSn: form.productSn,
+              productCode: form.productCode,
+              price: form.price,
+              cost: form.cost,
+              maxQty: form.maxQty
+            }
+          }
+          // 开始提交数据
           _this.spinning = true
-          saveHw(params).then(res => {
+          addPlaceAndProduct(params).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
-              _this.$emit('refresh')
-              setTimeout(function () {
-                _this.isshow = false
-                _this.spinning = false
-              }, 300)
+              _this.isShow = false
+              _this.$emit('ok', res.data)
+              _this.spinning = false
             } else {
               _this.spinning = false
             }
           })
         } else {
-          console.log('error submit!!')
           return false
         }
       })
+    },
+    resetData () {
+      this.form.productSn = undefined
+      this.form.productCode = undefined
+      this.form.price = ''
+      this.form.cost = ''
+      this.form.maxQty = ''
+      if (this.$refs.productJqList) {
+        this.$refs.productJqList.resetForm()
+      }
+      this.$refs.ruleForm.resetFields(['productSn'])
     }
   },
   watch: {
-    openHWModal (newValue, oldValue) {
-      console.log(newValue, 'newValue')
-      this.isshow = newValue
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
     },
-    isshow (newValue, oldValue) {
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
       if (!newValue) {
-        console.log(!newValue, newValue)
-        this.$refs.ruleForm.resetFields()
-        this.form = {}
-        this.textTitle = '新增货位'
         this.$emit('close')
+        this.resetData()
+        this.productName = ''
       } else {
-        if (this.nowData && this.nowData.id) { //  编辑
-          console.log(this.shelfPlaceSn, 'this.shelfPlaceSn')
-          this.textTitle = '编辑货位'
-          this.getShelfHWDetail()
+        if (this.type == 'edit') {
+          this.form.shelfPlaceCode = this.nowData.shelfPlaceCode
         }
       }
     }
   }
 }
 </script>
+
 <style lang="less">
+.shelfSet-newHw-modal {
+	.ant-modal-body {
+		padding: 40px 40px 24px;
+	}
+  .ant-form-item{
+    margin-bottom: 15px;
+  }
+	.btn-cont {
+		text-align: center;
+		margin: 35px 0 10px;
+	}
+}
 </style>

+ 18 - 13
src/views/numsGoodsShelves/shelfSet/basicInfoModal.vue

@@ -9,7 +9,7 @@
     @cancel="isShow = false"
     :width="600">
     <a-spin :spinning="spinning" tip="Loading...">
-      <p style="text-align: center;margin: 0 0 20px;font-size: 14px;font-weight: bold;">{{ nowData && nowData.shelfName || '--' }}</p>
+      <p v-if="type==0" style="text-align: center;margin: 0 0 20px;font-size: 14px;font-weight: bold;">{{ nowData && nowData.shelfName || '--' }}</p>
       <a-form-model
         id="shelfSet-basicInfo-form"
         ref="ruleForm"
@@ -17,7 +17,7 @@
         :rules="rules"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol">
-        <a-form-model-item label="货架名称" prop="shelfName">
+        <a-form-model-item label="货架名称" v-if="type==1" prop="shelfName">
           <a-input v-model="form.shelfName" placeholder="请输入货架名称"></a-input>
         </a-form-model-item>
         <a-form-model-item prop="customerSn">
@@ -60,6 +60,10 @@ export default {
       default: () => {
         return {}
       }
+    },
+    type: {
+      type: [String, Number],
+      default: '1'
     }
   },
   data () {
@@ -100,7 +104,7 @@ export default {
                 _this.isShow = false
                 _this.$emit('ok', res.data)
                 _this.spinning = false
-              }, 1000)
+              }, 100)
             } else {
               _this.spinning = false
             }
@@ -124,19 +128,20 @@ export default {
         this.$refs.ruleForm.resetFields()
         this.$refs.custList.resetForm()
       } else {
-        if (this.nowData.customerSn) {
-          const _this = this
-          this.$nextTick(() => {
-            _this.form.shelfName = _this.nowData.shelfName
-            _this.form.customerSn = _this.nowData.customerEntity && _this.nowData.customerEntity.customerSn
-            _this.$refs.custList.fetchUser(_this.nowData.customerEntity && _this.nowData.customerEntity.customerName)
+        const _this = this
+        this.$nextTick(() => {
+          _this.form.shelfName = _this.nowData.shelfName
+          const custome = _this.nowData.customerEntity
+          if (custome) {
+            _this.form.customerSn = custome.customerSn || ''
+            _this.$refs.custList.fetchUser(custome.customerName || '')
             _this.$refs.custList.dealerName = {
-              key: _this.nowData.customerEntity && _this.nowData.customerEntity.customerSn,
-              label: _this.nowData.customerEntity && _this.nowData.customerEntity.customerName,
+              key: custome.customerSn,
+              label: custome.customerName,
               row: _this.nowData
             }
-          })
-        }
+          }
+        })
       }
     }
   }

+ 11 - 11
src/views/numsGoodsShelves/shelfSet/bindProductModal.vue

@@ -22,10 +22,7 @@
           {{ productInfo&&productInfo.productCode }}
           <p style="margin: 0;">{{ productInfo&&productInfo.productName || '--' }}</p>
         </a-form-model-item>
-        <a-form-model-item label="绑定产品" prop="productSn" v-if="type == 'bind'">
-          <productJqList ref="productJqList" :params="{customerSn:nowData&&nowData.customerSn}" @change="productJqChange"></productJqList>
-        </a-form-model-item>
-        <a-form-model-item label="新绑定产品" prop="productSn" v-if="type == 'replace'">
+        <a-form-model-item :label="type!='bind'?'新绑定产品':'绑定产品'" prop="productSn" v-if="type!='edit'">
           <productJqList ref="productJqList" :params="{customerSn:nowData&&nowData.customerSn}" @change="productJqChange"></productJqList>
           <span v-if="form.productSn">{{ productName || '--' }}</span>
         </a-form-model-item>
@@ -123,9 +120,9 @@ export default {
       },
       rules: {
         productSn: [{ required: true, message: '请选择绑定产品', trigger: 'change' }],
-        price: [{ required: true, message: '请输入销售价', trigger: 'blur' }],
-        cost: [{ required: true, message: '请输入结算价', trigger: 'blur' }],
-        maxQty: [{ required: true, message: '请输入最大库容', trigger: 'blur' }]
+        price: [{ required: true, message: '请输入销售价', trigger: 'change' }],
+        cost: [{ required: true, message: '请输入结算价', trigger: 'change' }],
+        maxQty: [{ required: true, message: '请输入最大库容', trigger: 'change' }]
       },
       productName: '',
       productInfo: null
@@ -152,6 +149,7 @@ export default {
       this.form.price = obj && obj.row && obj.row.price || ''
       this.form.cost = obj && obj.row && obj.row.cost || ''
       this.productName = obj && obj.row && obj.row.name || ''
+      this.$refs.ruleForm.validate()
     },
     //  保存
     handleSave () {
@@ -202,6 +200,8 @@ export default {
       })
     },
     resetData () {
+      this.productName = ''
+      this.productInfo = null
       this.form.productSn = undefined
       this.form.productCode = undefined
       this.form.price = ''
@@ -210,7 +210,9 @@ export default {
       if (this.$refs.productJqList) {
         this.$refs.productJqList.resetForm()
       }
-      this.$refs.ruleForm.resetFields(['productSn'])
+      if (this.$refs.ruleForm) {
+        this.$refs.ruleForm.resetFields(['productSn'])
+      }
     }
   },
   watch: {
@@ -221,10 +223,8 @@ export default {
     //  重定义的弹框状态
     isShow (newValue, oldValue) {
       if (!newValue) {
-        this.$emit('close')
         this.resetData()
-        this.productName = ''
-        this.productInfo = null
+        this.$emit('close')
       } else {
         if (this.type != 'bind') { // 修改信息、更换产品
           this.getProductInfo()

+ 1 - 1
src/views/numsGoodsShelves/shelfSet/list.vue

@@ -77,7 +77,7 @@
       </s-table>
     </a-spin>
     <!-- 基础设置 -->
-    <basic-info-modal :openModal="openModal" :nowData="nowData" @ok="handleOk" @close="openModal=false" />
+    <basic-info-modal :type="0" :openModal="openModal" :nowData="nowData" @ok="handleOk" @close="openModal=false" />
   </a-card>
 </template>
 

+ 58 - 16
src/views/numsGoodsShelves/shelfSet/set.vue

@@ -75,23 +75,29 @@
               size="small"
               type="link"
               class="button-primary"
-              v-if="!!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
-              @click="handleProduct(record, 'edit')"
-              id="shelfMonitoringList-edit-btn">修改信息</a-button>
+              v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
+              @click="handleProduct(record, 'bind')"
+            >绑定产品</a-button>
             <a-button
               size="small"
               type="link"
               class="button-primary"
-              v-if="!!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
+              v-else
               @click="handleReplace(record)"
-              id="shelfMonitoringList-replace-btn">更换产品</a-button>
+            >更换产品</a-button>
             <a-button
               size="small"
               type="link"
               class="button-primary"
+              @click="editHW(record)"
+            >编辑</a-button>
+            <a-button
+              size="small"
+              type="link"
+              class="button-error"
               v-if="!(record.shelfProductApiEntity&&record.shelfProductApiEntity.productSn)"
-              @click="handleProduct(record, 'bind')"
-              id="shelfMonitoringList-bind-btn">绑定产品</a-button>
+              @click="handleDel(record)"
+            >删除</a-button>
           </template>
         </s-table>
       </a-card>
@@ -100,6 +106,8 @@
     <basic-info-modal :openModal="openInfoModal" :nowData="basicInfoData" @ok="handleInfoOk" @close="openInfoModal=false" />
     <!-- 修改信息/绑定产品/更换产品 -->
     <bind-product-modal :openModal="openModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
+    <!-- 编辑、新增货位 -->
+    <addHwModal :openModal="openHwModal" :type="modalType" :nowData="nowData" @ok="$refs.table.refresh()" @close="handleCancel" />
     <!-- 更换产品 -->
     <common-modal
       :openModal="openTipsModal"
@@ -112,8 +120,6 @@
     <importGuideModal :openModal="openGuideModal" :params="{shelfSn: $route.params.sn}" @close="openGuideModal=false" @ok="handleGuideOk" />
     <!-- 导入货位模板 -->
     <importHuoweiModal :openModal="openImportModal" @close="openImportModal=false" @ok="$refs.table.refresh(true)" :shelfSn="$route.params.sn"></importHuoweiModal>
-    <!-- 新增货位 -->
-    <addHWModal :openHWModal="openHWModal" @refresh="$refs.table.refresh(true)" :shelfSn="$route.params.sn" :nowData="nowData" @close="openHWModal=false"></addHWModal>
   </div>
 </template>
 
@@ -121,15 +127,15 @@
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import commonModal from '@/views/common/commonModal.vue'
+import addHwModal from './addHwModal.vue'
 import bindProductModal from './bindProductModal.vue'
 import ImportGuideModal from './importGuideModal.vue'
 import basicInfoModal from './basicInfoModal.vue'
 import importHuoweiModal from './importHuoweiModal.vue'
-import addHWModal from './addHWModal.vue'
-import { shelfDetail, shelfProductList, shelfProductBatchInsert } from '@/api/shelf'
+import { shelfDetail, shelfProductList, shelfProductBatchInsert, delShelfPlaceSn } from '@/api/shelf'
 export default {
   name: 'ShelfMonitoringWarehousing',
-  components: { STable, VSelect, commonModal, bindProductModal, ImportGuideModal, basicInfoModal, importHuoweiModal, addHWModal },
+  components: { STable, VSelect, commonModal, bindProductModal, addHwModal, ImportGuideModal, basicInfoModal, importHuoweiModal },
   mixins: [commonMixin],
   data () {
     return {
@@ -176,18 +182,33 @@ export default {
       openGuideModal: false,
       modalType: null,
       openInfoModal: false,
-      openHWModal: false,
+      openHwModal: false,
       openImportModal: false
     }
   },
   methods: {
-    // 导入或新增
+    // 导入或新增货位
     addHW (type) {
+      // 导入货位
       if (type == 0) {
         this.openImportModal = true
       } else {
-        this.nowData = null
-        this.openHWModal = true
+        // 新增货位
+        this.nowData = this.basicInfoData
+        this.modalType = 'new'
+        this.openHwModal = true
+      }
+    },
+    // 编辑货位
+    editHW (row) {
+      // 已绑定产品,不能编辑货位号,只能编辑已绑定产品的销售价、结算价、最大库容
+      if (row.shelfProductApiEntity && row.shelfProductApiEntity.productSn) {
+        this.handleProduct(row, 'edit')
+      } else {
+        // 货位没有绑定产品,仅编辑货位号
+        this.nowData = Object.assign(this.basicInfoData, row)
+        this.modalType = 'edit'
+        this.openHwModal = true
       }
     },
     // 基本信息
@@ -200,6 +221,25 @@ export default {
         }
       })
     },
+    // 删除货位
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '删除后无法恢复,确认删除?',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          delShelfPlaceSn({ shelfPlaceSn: row.shelfPlaceSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+            _this.spinning = false
+          })
+        }
+      })
+    },
     // 更换产品
     handleReplace (row) {
       if (row.shelfProductApiEntity.qty) {
@@ -219,8 +259,10 @@ export default {
       this.openModal = true
     },
     handleCancel () {
+      this.modalType = null
       this.nowData = null
       this.openModal = false
+      this.openHwModal = false
     },
     // 导入成功
     handleGuideOk (obj) {

+ 2 - 2
vue.config.js

@@ -211,8 +211,8 @@ const vueConfig = {
     // If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        // target: 'http://192.168.0.215:8076/qpls-md',
-        target: 'http://p.iscm.360arrow.com/qpls-md',
+        target: 'http://192.168.0.215:8076/qpls-md',
+        // target: 'http://p.iscm.360arrow.com/qpls-md',
         // ws: false,
         ws: true,
         changeOrigin: true,