charles
2024-08-06 5ecb7958c96d3f0b6d47b79aff7eb306c2cf690f
src/views/productManage/productCategory/index.vue
@@ -15,15 +15,20 @@
          ref="tableListRef"
          :table-list="tableList"
          :show-checkcol="false"
          :selectClassRow="selectRow"
          @tableRowClick="clickRow"
        >
          <template slot="tableButton">
            <el-table-column label="操作" width="90" align="center">
            <el-table-column label="操作" width="120" align="center">
              <template slot-scope="scope">
                <span @click.stop="showDetail(scope.row)" class="cursor_pointer" style="margin-right: 10px">
                  <span style="color: #2a78fb">查看</span>
                </span>
                <span @click.stop="editRow(scope.row)" class="cursor_pointer">
                  <span style="color: #2a78fb">编辑</span>
                </span>
                <span @click.stop="deleteRow(scope.row)" class="cursor_pointer">
                  <span style="color: #2a78fb;margin-left: 10px">删除</span>
                </span>
              </template>
            </el-table-column>
@@ -35,15 +40,15 @@
      </div>
    </div>
    <!-- 新建/编辑 -->
    <AddProductCategoryDialog v-if="editConfig.visible" :productCategoryList="tableList.tableInfomation" @refresh="refresh" :edit-common-config="editConfig" />
    <AddProductCategoryDialog ref="addProductCategory1" v-if="editConfig.visible" :productCategoryList="categoryList" @refresh="refresh" :edit-common-config="editConfig" />
  </div>
</template>
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getProductCategoryList } from "@/api/product/productCategory"
import { getProductCategoryList,deleteProductCategory } from "@/api/product/productCategory"
import AddProductCategoryDialog from "@/views/productManage/productCategory/AddProductCategoryDialog"
import {getTreeData} from '@/common/untils/index.js';
export default {
  name: "ProductCategory",
  props: {},
@@ -52,12 +57,14 @@
  computed: {},
  data() {
    return {
        selectRow:{},
      tableList: {},
        categoryList:[],
      searchOptions: [],
      editConfig: {
        visible: false,
        title: "新建",
        infomation: {},
        infomation: {parentId:0},
        autoEdit: false
      }
    }
@@ -67,8 +74,16 @@
    this.getData()
  },
  methods: {
      clickRow(row){
          if(row.id===this.selectRow.id){
              this.selectRow={};
          }else{
              this.selectRow={...row};
          }
      },
    setTable() {
      this.tableList = {
        key:"id",
        tableInfomation: [],
        selectBox: false,
        selectIndex: true,
@@ -90,9 +105,10 @@
        pageSize: this.pagerOptions.pageSize
      }).then((res) => {
        if (res.code === 200) {
          const list = res.data?res.data:[]
          this.tableList.tableInfomation = list
          this.pagerOptions.totalCount = res.total
          const list = res.data?res.data:[];
          this.categoryList=list;
          this.tableList.tableInfomation = getTreeData(list,'child');
          this.pagerOptions.totalCount = res.total;
        }
      })
    },
@@ -117,7 +133,7 @@
    editRow(row){
      this.editConfig.autoEdit = true
      this.editConfig.title = "编辑"
      this.editConfig.infomation = { ...row }
      this.editConfig.infomation = { ...row };
      this.editConfig.visible = true
    },
    // 新建
@@ -128,9 +144,35 @@
        forceRemovalStrategy:null,
        inventoryValuation:null,
        name:'',
        parentId:null,
        parentId:this.selectRow.id||0,
      }
      this.editConfig.visible = true
    },
    //删除
    deleteRow(row){
      this.$confirm('此操作将永久删除该产品类型, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            deleteProductCategory({
              id: row.id,
            }).then((res) => {
              if (res.code == 200) {
                this.$message({
                  type: 'success',
                  message: '删除成功!',
                })
                this.getData()
              }else{
                this.$message.error('删除时出错,请稍后重试或联系管理员...');
              }
            })
          })
          .catch(() => {})
    }
  }
}