catogaryDialog.vue 2.7 KB

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