Jelajahi Sumber

产品类别以及产品的修改

zhuliu 1 tahun lalu
induk
melakukan
55020ab907

+ 13 - 5
src/views/product/components/dialog/addEditCategory.vue

@@ -50,7 +50,7 @@
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button @click="handleClose" >取消</el-button>
-        <el-button type="primary" @click="submit" >确定</el-button>
+        <el-button type="primary" :loading="btnLoading" @click="submit" >确定</el-button>
       </div>
     </el-dialog>
 
@@ -79,7 +79,9 @@ export default {
       //待上传的文件
       file:[],
       //选择类型是管理人还是谁都可以看
-      chooseType:1
+      chooseType:1,
+      //按钮加载
+      btnLoading:false,
     };
   },
   mounted() { },
@@ -116,27 +118,33 @@ export default {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           var formData = new FormData()
+          this.form.guids = (this.form.systemFileList||[]).map(item=>{
+            return item.guid
+          })
           formData.append('productCategory',JSON.stringify(this.form))
           if(this.file.length>0){
             this.file.forEach(item=>{
               formData.append("files", item);
             })
           }
+          this.btnLoading = true
           if(this.form.id){
             this.$api.updateProductCategory(formData).then(response=>{
               this.$message.success('更新成功')
               this.$emit('getMessage','更新成功')
+              this.btnLoading = false
               this.handleClose()
             }).catch(error=>{
-
+              this.btnLoading = false
             })
           }else{
             this.$api.addProductCategory(formData).then(response=>{
               this.$message.success('添加成功')
-              this.$emit('getMessage','添加成功')
+              this.$emit('getMessage','')
+              this.btnLoading = false
               this.handleClose()
             }).catch(error=>{
-
+              this.btnLoading = false
             })
           }
           

+ 22 - 14
src/views/product/components/dialog/addEditProduct.vue

@@ -35,7 +35,7 @@
           </el-date-picker>
         </el-form-item>
         <el-form-item label="所属公司" prop="companyName">
-          <el-input v-model="form.companyName" :disabled="form.isTheCompany=='1' || form.id" placeholder="请输入所属公司"></el-input>
+          <el-input v-model="form.companyName" :disabled="form.tenantId?true:false" placeholder="请输入所属公司"></el-input>
         </el-form-item>
         <el-form-item label="参考许可费率" prop="licenseRate">
           <el-input v-model="form.licenseRate" placeholder="请输入参考许可费率(介于 0 ~ 1 之间)"></el-input>
@@ -80,7 +80,7 @@
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button @click="handleClose">取消</el-button>
-        <el-button type="primary" @click="submit">确定</el-button>
+        <el-button type="primary" :loading="btnLoading" @click="submit">确定</el-button>
       </div>
     </el-dialog>
     <choose-person ref="choosePerson" @getPersonIds="getPersonIds"></choose-person>
@@ -136,7 +136,9 @@ export default {
       //待上传的文件
       file:[],
       //选择类型是管理人还是谁都可以看
-      chooseType:1
+      chooseType:1,
+      //按钮加载
+      btnLoading:false,
     };
   },
   computed:{
@@ -187,27 +189,33 @@ export default {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           var formData = new FormData()
+          this.form.guids = (this.form.systemFileList||[]).map(item=>{
+            return item.guid
+          })
           formData.append('product',JSON.stringify(this.form))
           if(this.file.length>0){
             this.file.forEach(item=>{
               formData.append("files", item);
             })
           }
+          this.btnLoading = true
           if(this.form.id){
             this.$api.updateProduct(formData).then(response=>{
               this.$message.success('更新成功')
               this.$emit('getMessage','更新成功')
+              this.btnLoading = false
               this.handleClose()
             }).catch(error=>{
-
+              this.btnLoading = false
             })
           }else{
             this.$api.addProduct(formData).then(response=>{
               this.$message.success('添加成功')
-              this.$emit('getMessage','添加成功')
+              this.$emit('getMessage',this.form.categoryId)
+              this.btnLoading = false
               this.handleClose()
             }).catch(error=>{
-
+              this.btnLoading = false
             })
           }
           
@@ -263,14 +271,14 @@ export default {
           if(response.data.data && response.data.data.length == 0){
             this.isLazy = false
           }
-          if(this.form.categoryId){
-            var index = response.data.data.findIndex(item=>{
-              return item.id == this.form.categoryId
-            })
-            if(index!=-1){
-              response.data.data.splice(index,1)
-            }
-          }
+          // if(this.form.categoryId){
+          //   var index = response.data.data.findIndex(item=>{
+          //     return item.id == this.form.categoryId
+          //   })
+          //   if(index!=-1){
+          //     response.data.data.splice(index,1)
+          //   }
+          // }
           this.productCategoryList = [...this.productCategoryList, ...response.data.data];
         }
       }).catch(error=>{

+ 6 - 1
src/views/product/components/index.vue

@@ -46,7 +46,7 @@
     </el-container>
 
     <addEditCategory ref="addEditCategory" @getMessage="getMessage"></addEditCategory>
-    <addEditProduct ref="addEditProduct" @getMessage="getMessage"></addEditProduct>
+    <addEditProduct ref="addEditProduct" @getMessage="getMessage2"></addEditProduct>
     <marketing ref="marketing"></marketing>
     <myImageViewer v-if="showImg" :on-close="closeViewer" :src="imgSrc"></myImageViewer>
   </div>
@@ -285,9 +285,14 @@ export default {
     },
     //获取子组件信息
     getMessage(val){
+      this.handleMessage = val
       this.getList()
       this.clearMessage()
     },
+    getMessage2(val){
+      this.handleMessage = val
+      this.clearMessage()
+    },
     //清空信息
     clearMessage(){
       this.$nextTick(()=>{

+ 10 - 2
src/views/product/components/view/categoryTable.vue

@@ -1,11 +1,11 @@
 <template>
   <!-- 产品类别表格 -->
   <div class="categoryTable height_100" v-DivHeight="getDivHeight">
-    <el-table :data="tableData" style="width: 100%" header-row-class-name="custom-table-header" row-key="id" v-if="showTable" :maxHeight="tableHeight" @expand-change="handleExpand" @sort-change="sortChange">
+    <el-table :data="tableData" style="width: 100%" header-row-class-name="custom-table-header" row-key="id" v-if="showTable" :maxHeight="tableHeight" :expand-row-keys="expends" @expand-change="handleExpand" @sort-change="sortChange">
       <el-table-column type="expand">
         <!-- 产品 -->
         <template slot-scope="scope">
-          <div style="padding: 10px;">
+          <div style="padding: 10px;height: 340px;">
             <component :is="componentType" :tableData="scope.row.productData" :queryParams="scope.row.queryParams" :row="scope.row"  v-bind="$attrs" v-on="$listeners"></component>
           </div>
         </template>
@@ -95,6 +95,8 @@ export default {
     return {
       // 显示指定的子组件
       componentType: 'productTable',
+      //展开行数组
+      expends:[]
     }
   },
   mounted() {
@@ -104,6 +106,12 @@ export default {
    
     // 展开行打开或者关闭事件
     handleExpand(row, rowList) {
+      var index = this.expends.findIndex(item=>{
+        return item == row.id
+      })
+      if(index==-1){
+        this.expends.push(row.id)
+      }
       row.productData =row.productData || []
       row.queryParams =row.queryParams || {
         current:0,

+ 25 - 12
src/views/product/components/view/productTable.vue

@@ -1,7 +1,8 @@
 <template>
   <!-- 产品table -->
-  <div class="productTable height_100">
+  <div class="productTable height_100" v-DivHeight="getDivHeight">
     <el-table :data="tableData" header-row-class-name="custom-table-header" 
+      v-if="showTable" :maxHeight="tableHeight"
       v-el-table-infinite-scroll="getList"
       :infinite-scroll-distance="10"
       :infinite-scroll-disabled="disabled"
@@ -60,7 +61,10 @@
 </template>
 
 <script>
+import { getTableHeight } from '@/views/components/mixins'
+import product from '../mixins/product'
 export default {
+  mixins:[getTableHeight,product],
   props: {
     tableData: {
       type: Array,
@@ -73,7 +77,7 @@ export default {
       default: () => {
         return {
           current:0,
-          size:5
+          size:10
         }
       }
     },
@@ -136,7 +140,8 @@ export default {
       action:{
         type:'',//1表示删除,2表示其他,3表示新增
         id:''
-      }
+      },
+      data:JSON.parse(JSON.stringify(this.tableData))
     }
   },
   watch: {
@@ -165,18 +170,23 @@ export default {
           })
           this.tableData.splice(startIndex,1)
           var str = this.$commonJS.objectToString(this.searchOption) 
-        let params = {
-          ...this.params,
-          searchQuery:str?' AND ':'' + `category_id=${this.row.id}`,//检索条件
-          orderDTOList: this.sort,//排序
-        }
+          let params = {
+            ...this.queryParams,
+            searchQuery:str?' AND ':'' + `category_id=${this.row.id}`,//检索条件
+            orderDTOList: this.sort,//排序
+          }
         this.getList2(params,1)
       }else if(this.action.type == 2){
         let params = {
-          ...this.params,
+          ...this.queryParams,
           searchQuery:`product_id=${this.action.id}`,//检索条件
         }
         this.getList2(params,2)
+      }else{
+        this.queryParams.current = 0
+        this.disabled = false
+        this.tableData.splice(0)
+        this.getList()
       }
     },
 
@@ -189,7 +199,7 @@ export default {
             var endIndex = this.tableData.length
             var len = endIndex - startIndex
             this.tableData.splice(startIndex,len,...res.data.data)
-            this.params.total = res.data.total
+            this.queryParams.total = res.data.total
           }else if(type == 2){
             var startIndex = this.tableData.findIndex(item=>{
               return item.id == this.action.id
@@ -273,7 +283,7 @@ export default {
         params.orderType = orderType[order]
         this.sort.push(params)
       }
-      this.params.current = 0
+      this.queryParams.current = 0
       this.disabled = false
       this.tableData.splice(0)
       this.getList()
@@ -282,4 +292,7 @@ export default {
 }
 </script>
 
-<style lang="scss" scoped></style>
+<style lang="scss" scoped>
+.productTale{
+}
+</style>