Browse Source

产品类别对接

chenrui 4 years ago
parent
commit
ac299c2bb5

+ 28 - 0
src/api/dealerProductType.js

@@ -0,0 +1,28 @@
+import { axios } from '@/utils/request'
+
+//  产品类别列表  无分页
+export const dealerProductTypeQuery = (params) => {
+  const url = `/dealerProductType/query`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+
+// 新增/编辑产品类别
+export const dealerProductTypeSave = params => {
+  return axios({
+    url: '/dealerProductType/save',
+    data: params,
+    method: 'post'
+  })
+}
+
+// 删除产品类别
+export const dealerProductTypeDel = params => {
+  return axios({
+    url: `/dealerProductType/delete/${params.id}`,
+    method: 'get'
+  })
+}

+ 1 - 1
src/views/inventoryManagement/warehouse/list.vue

@@ -73,7 +73,7 @@ export default {
           return data
         })
       },
-      openModal: false,  //  新增编辑产品品牌  弹框
+      openModal: false,  //  新增编辑  弹框
       itemId: '',  //  当前id
       nowData: null  //  当前记录数据
     }

+ 55 - 25
src/views/productManagement/productCategory/editModal.vue

@@ -1,7 +1,7 @@
 <template>
   <a-modal
     centered
-    class="productBrandEdit-modal"
+    class="productCategoryEdit-modal"
     :footer="null"
     :maskClosable="false"
     :title="modalTit"
@@ -11,25 +11,23 @@
     <!-- 表单 -->
     <div>
       <a-form-model
-        id="productBrandEdit-form"
+        id="productCategoryEdit-form"
         ref="ruleForm"
         :model="form"
         :rules="rules"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol"
       >
-        <a-form-model-item label="产品品牌名称" prop="name">
-          <a-input
-            id="productBrandEdit-name"
-            :maxLength="30"
-            v-model="form.name"
-            placeholder="请输入产品品牌名称(最多30个字符)"
-            allowClear />
+        <a-form-model-item label="所属类别" v-if="parentType">
+          {{ parentType }}
+        </a-form-model-item>
+        <a-form-model-item label="产品类别名称" prop="productTypeName">
+          <a-input v-model.trim="form.productTypeName" id="productCategory-name" :maxLength="30" allowClear placeholder="请输入产品类别名称(最多30个字符)" />
         </a-form-model-item>
       </a-form-model>
       <div class="btn-cont">
-        <a-button type="primary" id="product-brand-edit-modal-save" @click="handleSave">保存</a-button>
-        <a-button id="product-brand-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
+        <a-button type="primary" id="product-category-edit-modal-save" @click="handleSave">保存</a-button>
+        <a-button id="product-category-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
       </div>
     </div>
   </a-modal>
@@ -37,8 +35,9 @@
 
 <script>
 import { STable } from '@/components'
+import { dealerProductTypeSave } from '@/api/dealerProductType'
 export default {
-  name: 'productBrandEditModal',
+  name: 'productCategoryEditModal',
   components: { STable },
   props: {
     openModal: { //  弹框显示状态
@@ -48,39 +47,55 @@ export default {
     itemId: {
       type: [Number, String],
       default: ''
+    },
+    nowData: {
+      type: Object,
+      default: null
     }
   },
   computed: {
     modalTit () {
-      return (this.itemId ? '编辑' : '新增') + '产品品牌'
+      return (this.itemId ? '编辑' : '新增') + '产品类别'
     }
   },
   data () {
     return {
       isShow: this.openModal, //  是否打开弹框
-      detailsData: null, //  品牌数据
       formItemLayout: {
         labelCol: { span: 6 },
         wrapperCol: { span: 16 }
       },
       form: {
-        name: '', // 产品品牌名称
+        productTypeName: '', // 产品类别名称
       },
       rules: {
-        name: [
-          { required: true, message: '请输入产品品牌名称', trigger: 'blur' }
+        productTypeName: [
+          { required: true, message: '请输入产品类别名称', trigger: 'blur' }
         ],
-      }
+      },
+      parentType: '',  //  父级分类
     }
   },
   methods: {
-    //  获取详情
-    getDetail(){
-      
-    },
     //  保存
     handleSave(){
-      
+      const _this = this
+      _this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const formData = JSON.parse(JSON.stringify(_this.form))
+          formData.id = _this.itemId ? _this.itemId : null
+          formData.psn = _this.nowData && _this.nowData.psn ? _this.nowData.psn : null
+          dealerProductTypeSave(formData).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$emit('ok')
+              _this.isShow = false
+            }
+          })
+        } else {
+          return false
+        }
+      })
     },
   },
   watch: {
@@ -92,11 +107,26 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
+      }else{
+        //  获取父级分类 名称
+        if(this.nowData && this.nowData.namePaths){
+          let namePathsArr = []
+          namePathsArr = this.nowData.namePaths.split(',')
+          this.parentType = ''
+          namePathsArr.map((item, index) => {
+            this.parentType += item + ' > '
+          })
+          this.parentType = this.parentType ? this.parentType.substr(0, this.parentType.length - 3) : ''
+        }else{
+          this.parentType = ''
+        }
       }
     },
     itemId (newValue, oldValue) {
       if (this.isShow && newValue) {
-        this.getDetail()
+        this.form.productTypeName = this.nowData && this.nowData.productTypeName ? this.nowData.productTypeName : ''
+      }else{
+        this.form.productTypeName = ''
       }
     }
   }
@@ -104,7 +134,7 @@ export default {
 </script>
 
 <style lang="less">
-  .productBrandEdit-modal{
+  .productCategoryEdit-modal{
     .ant-modal-body {
     	padding: 40px 40px 24px;
     }

+ 43 - 118
src/views/productManagement/productCategory/list.vue

@@ -2,7 +2,7 @@
   <a-card :bordered="false" class="productCategoryList-wrap">
     <!-- 操作按钮 -->
     <div class="table-operator">
-      <a-button id="productCategoryList-add" type="primary" @click="handleAdd" style="margin-top: 18px;">新增一级分类</a-button>
+      <a-button id="productCategoryList-add" type="primary" @click="handleAdd()" style="margin-top: 18px;">新增一级分类</a-button>
     </div>
     <!-- 列表 -->
     <s-table
@@ -18,12 +18,13 @@
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
         <a-button
+          v-if="record.productTypeLevel<3"
           type="link"
           size="small"
           icon="plus"
           class="btn-add-s"
           id="productCategory-addSubItem"
-          @click="handleAdd(text)">新增子级</a-button>
+          @click="handleAdd(record)">新增子级</a-button>
         <a-button
           v-if="record.pid != 0"
           type="link"
@@ -31,7 +32,7 @@
           icon="edit"
           class="btn-edit-s"
           id="productCategory-edit"
-          @click="handleEdit(text)">编辑</a-button>
+          @click="handleEdit(record)">编辑</a-button>
         <a-button
           v-if="record.pid != 0"
           type="link"
@@ -39,40 +40,20 @@
           icon="delete"
           class="btn-del-s"
           id="productCategory-del"
-          @click="handleDel(text)">删除</a-button>
+          @click="handleDel(record)">删除</a-button>
       </template>
     </s-table>
     <!-- 新增/编辑产品类别 -->
-    <a-modal
-      class="productCategoryList-modal"
-      centered
-      :title="title"
-      :visible="visible"
-      :footer="null"
-      :closable="true"
-      @cancel="onCancel"
-      :width="800">
-      <!-- 表单 -->
-      <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
-        <a-form-model-item label="产品类别名称" prop="name">
-          <a-input v-model.trim="form.name" id="productCategory-itemName" :maxLength="30" placeholder="请输入产品类别名称(最多30个字符)" />
-        </a-form-model-item>
-        <a-form-model-item class="btn-cont" :labelCol="{span: 0}" :wrapperCol="{span: 24}">
-          <a-button type="primary" id="productCategory-save" @click="onSubmit">保存</a-button>
-          <a-button class="cancel" id="productCategory-cancel" @click="onCancel">取消</a-button>
-        </a-form-model-item>
-      </a-form-model>
-    </a-modal>
+    <product-category-edit-modal :openModal="openModal" :nowData="nowData" :itemId="itemId" @ok="handleOk" @close="closeModal" />
   </a-card>
 </template>
 
 <script>
-import moment from 'moment'
-// import { customerBundleDelayList, customerBundleExportDelay } from '@/api/FinancialManagement'
-import { STable, VSelect } from '@/components'
+import { dealerProductTypeQuery, dealerProductTypeDel } from '@/api/dealerProductType'
+import { STable } from '@/components'
 import productCategoryEditModal from './editModal.vue'
 export default {
-  components: { STable, VSelect, productCategoryEditModal },
+  components: { STable, productCategoryEditModal },
   data () {
     return {
       formItemLayout: {
@@ -80,103 +61,56 @@ export default {
         wrapperCol: { span: 16 }
       },
       columns: [
-        { title: '组织机构名称', dataIndex: 'name', width: 200, align: 'left' },
+        { title: '产品类别名称', dataIndex: 'productTypeName', width: 200, align: 'left' },
+        { title: '首字母', dataIndex: 'sss', width: 150, align: 'center' },
         { title: '创建时间', dataIndex: 'createDate', width: 150, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
-        // return customerBundleDelayList( Object.assign(parameter, this.queryParam) ).then(res => {
-        //   const data = res.data
-        //   const no = (data.pageNo - 1) * data.pageSize
-        //   for (var i = 0; i < data.list.length; i++) {
-        //     data.list[i].no = no + i + 1
-        //   }
-        //   this.disabled = false
-        //   return data
-        // })
-        // return findOrgTree().then(res => {
-        //   //  递归去除空children
-        //   this.recursionFun(res.data)
-        //   this.defaultExpandedRowKeys[0] = res.data[0].id
-        //   return res.data
-        // })
-        const _this = this
-        return new Promise(function(resolve, reject){
-          const data = {
-            pageNo: 1,
-            pageSize: 10,
-            list: [
-              { id: '1', productNum: 'jgqp11111111111', productName: '产品1', productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
-            ]
-          }
-          const no = (data.pageNo - 1) * data.pageSize
-          for (var i = 0; i < data.list.length; i++) {
-            data.list[i].no = no + i + 1
-          }
-          _this.disabled = false
-          resolve(data)
+        return dealerProductTypeQuery({}).then(res => {
+          //  递归去除空children
+          this.recursionFun(res.data)
+          this.defaultExpandedRowKeys[0] = res.data[0].id
+          return res.data
         })
       },
-      title: '新增', //  对话框标题
-      visible: false, //  对话框是否可见
-      form: { //  新增编辑  组织机构
-        name: ''
-      },
-      rules: { //  表单校验规则
-        name: [{ required: true, message: '请输入组织机构名称', trigger: 'blur' }]
-      },
-      nowId: '', //  当前操作的数据id
-      nowPid: '', //  当前操作的数据上级id
-      defaultExpandedRowKeys: [] //  树形数据默认展开项
+      defaultExpandedRowKeys: [], //  树形数据默认展开项
+      openModal: false,  //  新增编辑  弹框
+      itemId: '',  //  当前id
+      nowData: null  //  当前记录数据
     }
   },
   methods: {
     //  新增子级
-    handleAdd (item) {
-      this.nowId = ''
-      this.form.name = ''
-      if (item) { //  子级
-        this.nowPid = item.id
-      } else { //  最高级
-        this.nowPid = ''
+    handleAdd (row) {
+      this.itemId = null
+      if(row){  //  新增子级
+        let nowData = row
+        nowData.psn = nowData && nowData.productTypeSn ? nowData.productTypeSn : null
+        this.nowData = nowData
+      }else{  //  最高级
+        this.nowData = null
       }
-      this.title = '新增'
-      this.visible = true
+      this.openModal = true
     },
     //  编辑
-    handleEdit (item) {
-      this.nowId = item.id
-      this.nowPid = item.pid
-      this.title = '编辑'
-      this.form.name = item.name
-      this.visible = true
+    handleEdit (row) {
+      this.itemId = row && row.id ? row.id : null
+      let nowData = row
+      nowData.psn = nowData && nowData.productTypeSn ? nowData.productTypeSn : null
+      this.nowData = nowData
+      this.openModal = true
     },
-    //  保存
-    onSubmit () {
-      const _this = this
-      _this.$refs.ruleForm.validate(valid => {
-        if (valid) {
-          const formData = JSON.parse(JSON.stringify(_this.form))
-          formData.id = _this.nowId
-          formData.pid = _this.nowPid
-          saveAtorg(formData).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$refs.table.refresh(true)
-              _this.visible = false
-            }
-          })
-        } else {
-          return false
-        }
-      })
+    //  关闭弹框
+    closeModal(){
+      this.itemId = ''
+      this.openModal = false
     },
-    //  关闭对话框
-    onCancel () {
-      this.$refs.ruleForm.resetFields()
-      this.visible = false
+    //  新增/编辑  成功
+    handleOk(){
+      this.$refs.table.refresh(true)
     },
     //  删除
     handleDel (item) {
@@ -187,7 +121,7 @@ export default {
         centered: true,
         content: '删除后原数据不可恢复,是否删除?',
         onOk () {
-          delAtorg({ id: _this.nowId }).then(res => {
+          dealerProductTypeDel({ id: _this.nowId }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$refs.table.refresh()
@@ -233,13 +167,4 @@ export default {
       }
     }
   }
-  // 弹框
-  .productCategoryList-modal{
-    .btn-cont{
-      text-align: center;
-      .cancel {
-        margin-left: 50px;
-      }
-    }
-  }
 </style>