catogaryDialog.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <ele-modal
  3. :visible.sync="visible"
  4. :title="categoryLevelId == 5 ? '选择模具' : '选择舟皿'"
  5. width="65vw"
  6. append-to-body
  7. :maxable="true"
  8. >
  9. <div class="search-box">
  10. 编码/名称
  11. <el-input placeholder="请输入" v-model="searchKey"></el-input>
  12. </div>
  13. <!-- 数据表格 -->
  14. <ele-pro-table
  15. ref="tableRef"
  16. :columns="columns"
  17. :key="categoryLevelId"
  18. @done="handleDone"
  19. row-key="id"
  20. cache-key="materialDialogtable"
  21. :datasource="datasource"
  22. :current.sync="current"
  23. highlight-current-row
  24. height="45vh"
  25. >
  26. </ele-pro-table>
  27. <div class="footer" slot="footer">
  28. <el-button @click="cancel">取消</el-button>
  29. <el-button @click="confirm" type="primary">确定</el-button>
  30. </div>
  31. </ele-modal>
  32. </template>
  33. <script>
  34. import { getList } from '@/api/classifyManage/itemInformation';
  35. export default {
  36. data() {
  37. return {
  38. visible: false,
  39. current: null,
  40. callback: null,
  41. categoryLevelId: '',
  42. searchKey: ''
  43. };
  44. },
  45. computed: {
  46. columns() {
  47. const list = [
  48. {
  49. label: '编码',
  50. prop: 'code'
  51. },
  52. {
  53. label: '名称',
  54. prop: 'name'
  55. },
  56. {
  57. label: '牌号',
  58. prop: 'brandNum'
  59. }
  60. ];
  61. return list;
  62. }
  63. },
  64. methods: {
  65. open(categoryLevelId, memo, callback) {
  66. this.categoryLevelId = categoryLevelId;
  67. this.memo = memo;
  68. this.callback = callback;
  69. this.visible = true;
  70. },
  71. reload() {
  72. this.$refs.tableRef.reload();
  73. },
  74. handleDone({ data }) {
  75. if (this.memo?.id) {
  76. this.$nextTick(() => {
  77. this.$refs.tableRef.setCurrentRow(
  78. data.find((item) => item.id == this.memo.id)
  79. );
  80. });
  81. }
  82. },
  83. datasource({ page, limit }) {
  84. return getList({
  85. pageNum: page,
  86. size: limit,
  87. isProduct: true,
  88. categoryLevelId: this.categoryLevelId,
  89. searchKey: this.searchKey
  90. });
  91. },
  92. confirm() {
  93. if (!this.current) return this.$message.error('请选择数据');
  94. this.callback && this.callback(this.current);
  95. this.cancel();
  96. },
  97. cancel() {
  98. this.$refs.tableRef.setCurrentRow();
  99. this.searchKey = '';
  100. this.current = null;
  101. this.visible = false;
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. .search-box {
  108. display: flex;
  109. justify-content: flex-start;
  110. align-items: center;
  111. margin-bottom: 20px;
  112. .el-input {
  113. width: 220px;
  114. margin: 0 32px;
  115. }
  116. }
  117. </style>