1
lzhe
2024-06-05 dcf9c9e0410fe1186239e3f8d6f7bdc789c08010
src/views/console/basic-data/product.vue
@@ -47,6 +47,44 @@
                     <el-icon @click="addDrawer" class="searchi-icon"><Setting /></el-icon>
                  </el-col>
               </el-row>
               <div class="product-type-table">
                  <el-table ref="multipleTableRef0" :data="productTableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange0" row-key="id" lazy :load="tableLoad" :tree-props="{ hasChildren: 'hasChild' }">
                     <el-table-column type="selection" width="55" />
                     <el-table-column prop="name" label="产品名称"></el-table-column>
                     <el-table-column prop="code" label="产品编号"></el-table-column>
                     <el-table-column prop="typeName" label="产品类型"></el-table-column>
                     <el-table-column prop="unit" label="计量单位"></el-table-column>
                     <el-table-column prop="standardModel" label="规格型号"></el-table-column>
                     <el-table-column prop="description" label="产品描述"></el-table-column>
                     <el-table-column prop="remark" label="工艺路线">
                        <template #default="scope">
                             <span class="viewDetial">查看详情</span>
                          </template>
                     </el-table-column>
                     <el-table-column prop="remark" label="BOM清单">
                        <template #default="scope">
                             <span class="viewDetial">查看详情</span>
                          </template>
                     </el-table-column>
                     <el-table-column fixed="right" label="操作" width="200px">
                        <template #default="scope">
                           <el-button text type="primary" size="small" @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                           <el-button text type="primary" size="small" @click="refresh_product_type(scope.row, scope.$index)">刷新</el-button>
                           <el-button text type="primary" size="small" @click="del_product_type(scope.row, scope.$index,0)">删除</el-button>
                        </template>
                     </el-table-column>
                  </el-table>
                  <el-pagination
                     style="margin-top: 12px;"
                     @size-change="handleSizeChange0"
                     @current-change="handleCurrentChange0"
                     :current-page="currentPage4"
                     :page-sizes="[15, 50, 100]"
                     :page-size="15"
                     layout="total, sizes, prev, pager, next, jumper"
                     :total="total0">
                  </el-pagination>
               </div>
               <el-drawer title="查询设置" v-model="drawer" :direction="direction" :before-close="handleClose" size="780" class="drawerClass">
                  <div class="drawer-form">
                     <div class="drawer-left">
@@ -92,7 +130,7 @@
                  </el-col>
               </el-row>
               <div class="product-type-table">
                  <el-table ref="multipleTableRef" :data="productTypeTableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange">
                  <el-table ref="multipleTableRef1" :data="productTypeTableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange1">
                     <el-table-column type="selection" width="55" />
                     <el-table-column prop="name" label="产品类型名称"></el-table-column>
                     <el-table-column prop="remark" label="描述"></el-table-column>
@@ -103,14 +141,14 @@
                     </el-table-column>
                     <el-table-column fixed="right" label="操作">
                        <template #default="scope">
                           <el-button text type="primary" size="small" @click="del_product_type(scope.row, scope.$index)">删除</el-button>
                           <el-button text type="primary" size="small" @click="del_product_type(scope.row, scope.$index,1)">删除</el-button>
                        </template>
                     </el-table-column>
                  </el-table>
                  <el-pagination
                     style="margin-top: 12px;"
                     @size-change="handleSizeChange"
                     @current-change="handleCurrentChange"
                     @size-change="handleSizeChange1"
                     @current-change="handleCurrentChange1"
                     :current-page="currentPage4"
                     :page-sizes="[15, 50, 100]"
                     :page-size="15"
@@ -150,6 +188,8 @@
      name: "allocation",
      data(){
         return {
            total0: 0,
            productTableData: [],
            checkData: [],
            checkList: [],
            id: "",
@@ -167,7 +207,8 @@
            uploadUrl: "/api/blade-cps/employee/import-employee",
            exportUrl: "/api/blade-cps/employee/export-template",
            activeName: 'first',
            selection: [],
            selection0: [],
            selection1: [],
            total: 0,
            searchData: {
               keyWord: "",
@@ -180,14 +221,15 @@
            dialog: {
               save: false
            },
            tableData: []
            tableData: [],
            delTypeNum: ""
         }
      },
      created(){
         
      },
      mounted(){
         //this.searchBtn();
         this.searchBtn0();
         this.getProductType();
         this.getProductTypeSelect();
         this.getFields();  //查询设置
@@ -196,6 +238,14 @@
         ...ElementPlusIconsVue,saveDialog,importTable
      },
      methods: {
         tableLoad(row,treeNode,resolve) {
            this.searchData.parentId= row.id;
            this.$HTTP.post(`/api/blade-cps/product/lazy/tree?current=1&size=-1&id=${row.id}`).then(res=> {
               if(res.code == 200) {
                  resolve(res.data.records);
               }
            })
         },
         delIcon(index) {
            this.checkData.splice(index,1);
         },
@@ -210,8 +260,15 @@
            })
         },
         delTypeDataSingle(type) {
            if(this.delTypeNum == 0) {  //删除产品
               var url = "/api/blade-cps/product/remove";
               var stopUrl = "/api/blade-cps/product/change-status";
            }else if(this.delTypeNum == 1) {  //删除产品类型
               var url = "/api/blade-cps/product-type/remove";
               var stopUrl = "/api/blade-cps/product-type/change-status";
            }
            if(type == 0) {  //删除
               this.$HTTP.delete(`/api/blade-cps/product-type/remove`,[this.id]).then(res=> {
               this.$HTTP.delete(url,[this.id]).then(res=> {
                  if(res.code == 200) {
                     this.$message.success("操作成功");
                     this.delTypeModel = false;
@@ -224,7 +281,7 @@
                  ids: [this.id],
                  status: 0
               }
               this.$HTTP.put(`/api/blade-cps/product-type/change-status`,obj).then(res=> {
               this.$HTTP.put(stopUrl ,obj).then(res=> {
                  if(res.code == 200) {
                     this.$message.success("操作成功");
                     this.delTypeModel = false;
@@ -261,7 +318,8 @@
               }
            })
         },
         del_product_type(row) {
         del_product_type(row,index,type) {
            this.delTypeNum = tyype;
            this.id = row.id;
            this.delTypeModel = true;
         },
@@ -302,7 +360,7 @@
              done();
          },
         getExport() {
            this.$HTTP.get(`/api/blade-cps/employee/export-employee?` + this.$TOOL.qsStringify(this.searchData)).then(res => {
            this.$HTTP.post(`/api/blade-cps/product/export-product`,this.searchData).then(res => {
               if (res.code == 200) {
                  window.open(res.data.link);
               }
@@ -322,23 +380,28 @@
         },
         searchClearBtn() {
            this.searchData = {
               code: "",
               ProductValue: "",
               keyWord: "",
               standardModel: "",
               status: "1",
               typeId: [],
               current: "1",
               size: "15"
            }
            this.searchBtn();
            this.searchBtn0();
         },
         refresh_product_type() {
            this.searchClearBtn();
         },
         searchclick() {
            this.searchData.current = "1";
            this.searchData.size = "15";
            this.searchBtn();
            this.searchBtn0();
         },
         searchBtn() {
            this.$HTTP.get("/api/blade-system/Product/parent-list",this.searchData).then(res=> {
         searchBtn0() {
            this.$HTTP.post("/api/blade-cps/product/lazy/tree?current=1&size=15&id=0",this.searchData).then(res=> {
               if(res.code == 200) {
                  this.tableData = res.data.records;
                  this.total = res.data.total;
                  this.productTableData = res.data.records;
                  this.total0 = res.data.total;
               }
            })
         },
@@ -358,7 +421,7 @@
               this.$HTTP.post("/api/blade-system/Product/remove?ids="+row.id).then(res=> {
                  if(res.code == 200) {
                     that.$message.success("操作成功");
                     that.searchBtn();
                     that.searchBtn1();
                  }
               })
            }).catch(() => {
@@ -369,16 +432,16 @@
         addData(){
            this.dialog.save = true
            this.$nextTick(() => {
               this.$refs.saveDialog.open()
               this.$refs.saveDialog.open(this.typeIdList)
            })
         },
         table_edit(row){
            this.dialog.save = true
            this.$HTTP.get("/api/blade-system/Product/detail?id="+row.id).then(res=> {
            this.$HTTP.get(`/api/blade-cps/product/get/${row.id}`).then(res=> {
               if(res.code == 200) {
                  this.dialog.save = true;
                  this.$nextTick(() => {
                     this.$refs.saveDialog.open('edit').setData(res.data);
                     this.$refs.saveDialog.open(this.typeIdList,'edit').setData(res.data);
                  })
               }
            })
@@ -390,46 +453,66 @@
               this.$refs.saveDialog.open('show').setData(row)
            })
         },
         handleSelectionChange(selection) {
            this.selection = selection;
         handleSelectionChange0(selection) {
            this.selection0 = selection;
         },
         handleSelectionChange1(selection) {
            this.selection1 = selection;
         },
         addTypeData() {
            this.isAddType = true;
         },
         delTypeData() {
         },
         delData() {
            if(this.selection.length == 0) {
            if(this.selection1.length == 0) {
               this.$message({
                   message: '请选择至少一条数据',
                   type: 'warning'
                 });
                 return;
            }
            var selStr = "";
            this.selection.map(item=> {
               selStr += item.id + ","
            })
            selStr = selStr.replace(/,$/, '');
            var that = this;
            this.$HTTP.post("/api/blade-system/Product/remove?ids="+selStr).then(res=> {
               if(res.code == 200) {
                  that.$message.success("操作成功");
                  that.searchclick();
               }
            })
         },
         handleSizeChange(val) {
         delData() {
            if(this.selection0.length == 0) {
               this.$message({
                   message: '请选择至少一条数据',
                   type: 'warning'
                 });
                 return;
            }
            // var selStr = "";
            // this.selection1.map(item=> {
            //    selStr += item.id + ","
            // })
            // selStr = selStr.replace(/,$/, '');
            // var that = this;
            // this.$HTTP.post("/api/blade-system/Product/remove?ids="+selStr).then(res=> {
            //    if(res.code == 200) {
            //       that.$message.success("操作成功");
            //       that.searchclick();
            //    }
            // })
         },
         handleSizeChange0(val) {
            console.log(`每页 ${val} 条`);
            this.searchData.current = "1";
            this.searchData.size = val;
            this.searchBtn();
            this.searchBtn0();
         },
         handleCurrentChange(val) {
         handleCurrentChange0(val) {
            console.log(`当前页: ${val}`);
            this.searchData.current = val;
            this.searchBtn();
            this.searchBtn0();
         },
         handleSizeChange1(val) {
            console.log(`每页 ${val} 条`);
            this.searchData.current = "1";
            this.searchData.size = val;
            this.searchBtn1();
         },
         handleCurrentChange1(val) {
            console.log(`当前页: ${val}`);
            this.searchData.current = val;
            this.searchBtn1();
         }
      }
   }
@@ -446,7 +529,7 @@
      padding-right: 8px;
      margin-bottom: 8px;
   }
   .multipleTableRef {
   .multipleTableRef1,.multipleTableRef0 {
      margin-bottom: 8px;
   }
   .search-condition {
@@ -498,7 +581,6 @@
   .delBtn:nth-child(1) {
      margin-right: 4px;
   }
   .delBtn:hover {
      background-color: #f34d5b;
      border-color: #f34d5b;
@@ -546,4 +628,8 @@
      display: inline-block;
      min-width: 80px;
   }
   .viewDetial {
      color: #337ecc;
      cursor: pointer;
   }
</style>