index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="75%"
  11. >
  12. <el-card shadow="never">
  13. <ProductSearch @search="reload" ref="searchRef" />
  14. <ele-split-layout
  15. width="244px"
  16. allow-collapse
  17. :right-style="{ overflow: 'hidden' }"
  18. >
  19. <div class="ele-border-lighter split-layout-right-content">
  20. <AssetTree
  21. ref="assetTreeRef"
  22. :id="categoryLevelId"
  23. @handleNodeClick="handleNodeClick"
  24. />
  25. </div>
  26. <!-- 表格 -->
  27. <template v-slot:content>
  28. <ele-pro-table
  29. ref="table"
  30. :columns="columns"
  31. :datasource="datasource"
  32. :selection.sync="selection"
  33. row-key="id"
  34. height="calc(100vh - 350px)"
  35. class="dict-table"
  36. >
  37. </ele-pro-table>
  38. </template>
  39. </ele-split-layout>
  40. </el-card>
  41. <div class="btns">
  42. <el-button type="primary" size="small" @click="selected">选择</el-button>
  43. <el-button size="small" @click="handleClose">关闭</el-button>
  44. </div>
  45. </el-dialog>
  46. </template>
  47. <script>
  48. import AssetTree from '@/components/AssetTree';
  49. import ProductSearch from '@/views/technology/productParam/components/product-search.vue';
  50. import { getMaterialList } from '@/api/material/list.js';
  51. export default {
  52. components: { AssetTree, ProductSearch },
  53. data() {
  54. return {
  55. visible: false,
  56. // 表格列配置
  57. columns: [
  58. {
  59. columnKey: 'selection',
  60. type: 'selection',
  61. width: 45,
  62. align: 'center',
  63. selectable: (row) => {
  64. return !this.processData?.some((it) => it.id == row.id);
  65. },
  66. reserveSelection: true,
  67. fixed: 'left'
  68. },
  69. {
  70. columnKey: 'index',
  71. type: 'index',
  72. width: 45,
  73. align: 'center',
  74. reserveSelection: true
  75. },
  76. {
  77. prop: 'code',
  78. label: '编码'
  79. },
  80. {
  81. prop: 'name',
  82. label: '名称',
  83. showOverflowTooltip: true
  84. },
  85. {
  86. prop: 'brandNum',
  87. label: '牌号'
  88. },
  89. {
  90. prop: 'modelType',
  91. label: '型号',
  92. align: 'center',
  93. showOverflowTooltip: true
  94. },
  95. {
  96. prop: 'specification',
  97. label: '规格',
  98. align: 'center',
  99. showOverflowTooltip: true
  100. },
  101. {
  102. prop: 'measuringUnit',
  103. label: '计量单位',
  104. showOverflowTooltip: true,
  105. minWidth: 90
  106. },
  107. {
  108. prop: 'weightUnit',
  109. label: '重量单位',
  110. showOverflowTooltip: true,
  111. minWidth: 90
  112. },
  113. {
  114. prop: 'roughWeight',
  115. label: '毛重',
  116. showOverflowTooltip: true,
  117. minWidth: 90
  118. },
  119. {
  120. prop: 'netWeight',
  121. label: '净重',
  122. showOverflowTooltip: true,
  123. minWidth: 90
  124. },
  125. {
  126. prop: 'packingUnit',
  127. align: 'center',
  128. label: '包装单位',
  129. showOverflowTooltip: true
  130. },
  131. {
  132. prop: 'categoryLevelPath',
  133. label: '分类',
  134. align: 'center',
  135. showOverflowTooltip: true
  136. },
  137. {
  138. action: 'action',
  139. slot: 'action',
  140. align: 'center',
  141. label: '选择'
  142. }
  143. ],
  144. // 表格选中数据
  145. selection: [],
  146. processData: [],
  147. title: null,
  148. categoryLevelId: null,
  149. current: null,
  150. isCategory: true
  151. };
  152. },
  153. watch: {},
  154. methods: {
  155. /* 表格数据源 */
  156. datasource({ page, where, limit }) {
  157. return getMaterialList({
  158. ...where,
  159. pageNum: page,
  160. size: limit,
  161. categoryLevelId: this.isCategory ? this.categoryLevelId : null
  162. });
  163. },
  164. handleNodeClick(data) {
  165. this.isCategory = true;
  166. this.categoryLevelId = data.id;
  167. this.$refs.table.reload({ pageNum: 1, where: {} });
  168. this.$refs.searchRef.reset2();
  169. },
  170. /* 刷新表格 */
  171. reload(where) {
  172. this.isCategory = false;
  173. this.$refs.table.reload({ pageNum: 1, where: where });
  174. },
  175. open(item, title, categoryLevelId, current) {
  176. this.processData = item;
  177. this.title = title;
  178. this.categoryLevelId = categoryLevelId;
  179. this.current = current;
  180. this.visible = true;
  181. },
  182. handleClose() {
  183. this.visible = false;
  184. this.$refs.table.setSelectedRows([]);
  185. this.selection = [];
  186. },
  187. selected() {
  188. if (!this.selection.length) {
  189. this.$message.error('请最少选择一条数据');
  190. return;
  191. }
  192. console.log(this.current);
  193. this.$emit('chooseProcess', this.selection, this.current);
  194. this.handleClose();
  195. }
  196. }
  197. };
  198. </script>
  199. <style lang="scss" scoped>
  200. .tree_col {
  201. border: 1px solid #eee;
  202. padding: 10px 0;
  203. box-sizing: border-box;
  204. height: 500px;
  205. overflow: auto;
  206. }
  207. .table_col {
  208. padding-left: 10px;
  209. ::v-deep .el-table th.el-table__cell {
  210. background: #f2f2f2;
  211. }
  212. }
  213. .pagination {
  214. text-align: right;
  215. padding: 10px 0;
  216. }
  217. .btns {
  218. text-align: center;
  219. padding: 10px 0;
  220. }
  221. .topsearch {
  222. margin-bottom: 15px;
  223. }
  224. </style>