classify_list-small.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <!-- 添加类别弹窗 -->
  3. <el-dialog
  4. title="添加分类"
  5. :visible.sync="showAddSelect"
  6. :show-close="false"
  7. width="40%"
  8. :close-on-click-modal="false"
  9. >
  10. <!-- 列表 -->
  11. <div class="table">
  12. <el-table
  13. v-loading="listLoading"
  14. :data="dataList"
  15. element-loading-text="Loading"
  16. border
  17. fit
  18. highlight-current-row
  19. stripe
  20. @selection-change="selectionChangeFn"
  21. >
  22. <el-table-column type="selection" width="55" align="center">
  23. </el-table-column>
  24. <el-table-column
  25. align="center"
  26. label="编码"
  27. prop="number"
  28. min-width="160"
  29. show-overflow-tooltip
  30. ></el-table-column>
  31. <el-table-column
  32. align="center"
  33. label="类别名称"
  34. prop="name"
  35. min-width="160"
  36. show-overflow-tooltip
  37. ></el-table-column>
  38. </el-table>
  39. </div>
  40. <div slot="footer" class="dialog-footer">
  41. <el-button @click="cancelFn">取 消</el-button>
  42. <el-button type="primary" @click="btnOK">确 定</el-button>
  43. </div>
  44. </el-dialog>
  45. </template>
  46. <script>
  47. import {
  48. getProductCategoryKingDeeCategoryList,
  49. getProductCategoryAddSub,
  50. } from "@/api/basic_data/material";
  51. export default {
  52. props: {
  53. showAddSelect: {
  54. type: Boolean,
  55. required: true,
  56. },
  57. dataCategory: {
  58. type: Object,
  59. default: {},
  60. },
  61. data: {
  62. type: Array,
  63. default: [],
  64. },
  65. },
  66. data() {
  67. return {
  68. dataList: null, // 列表数据
  69. listLoading: false, // 列表加载loading
  70. arr: [],
  71. };
  72. },
  73. created() {
  74. // this.getDataList();
  75. },
  76. methods: {
  77. //获取选择的数据
  78. selectionChangeFn(v) {
  79. console.log(v);
  80. this.arr = v.map((item) => {
  81. return { kingDeeCategoryId: item.id };
  82. });
  83. },
  84. //获取列表数据
  85. async getDataList() {
  86. const res = await getProductCategoryKingDeeCategoryList();
  87. this.dataList = res.data;
  88. },
  89. //取消
  90. cancelFn() {
  91. this.$emit("update:showAddSelect", false);
  92. },
  93. //确定
  94. async btnOK() {
  95. console.log(this.data);
  96. let res = this.data.map((v) => {
  97. return { kingDeeCategoryId: v.kingDeeCategoryId };
  98. });
  99. let data = {
  100. productCategoryId: this.dataCategory.productCategoryId,
  101. productCategoryName: this.dataCategory.productCategoryName,
  102. productCategoryNumber: this.dataCategory.productCategoryNumber,
  103. items: [...this.arr, ...res],
  104. };
  105. await getProductCategoryAddSub(data);
  106. this.$message.success("新增成功");
  107. this.$emit("updateList", this.dataCategory.productCategoryId);
  108. this.$emit("update:showAddSelect", false);
  109. },
  110. },
  111. };
  112. </script>
  113. <style>
  114. </style>