standardOutput.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. <!-- 选择产品分类 -->
  13. <el-card shadow="never">
  14. <ProductSearch @search="reload" ref="searchRef" />
  15. <ele-split-layout
  16. width="244px"
  17. allow-collapse
  18. :right-style="{ overflow: 'hidden' }"
  19. >
  20. <div class="ele-border-lighter split-layout-right-content">
  21. <el-tree
  22. :data="treeList"
  23. :props="defaultProps"
  24. ref="treeRef"
  25. :default-expanded-keys="current && current.id ? [current.id] : []"
  26. :highlight-current="true"
  27. node-key="id"
  28. @node-click="handleNodeClick"
  29. ></el-tree>
  30. </div>
  31. <!-- 表格 -->
  32. <template v-slot:content>
  33. <ele-pro-table
  34. ref="table"
  35. :columns="columns"
  36. :datasource="datasource"
  37. :selection.sync="selection"
  38. row-key="id"
  39. height="calc(100vh - 350px)"
  40. class="dict-table"
  41. >
  42. </ele-pro-table>
  43. </template>
  44. </ele-split-layout>
  45. </el-card>
  46. <div class="btns">
  47. <el-button type="primary" size="small" @click="selected">选择</el-button>
  48. <el-button size="small" @click="handleClose">关闭</el-button>
  49. </div>
  50. </el-dialog>
  51. </template>
  52. <script>
  53. import ProductSearch from '@/components/select/bom/product-search.vue';
  54. import { getMaterialList } from '@/api/material/list.js';
  55. import { sourceBomVersion } from '@/api/material/BOM';
  56. import { getTreeByGroup } from '@/api/classifyManage';
  57. export default {
  58. components: { ProductSearch },
  59. data() {
  60. return {
  61. visible: false,
  62. type: 1,
  63. selection: [],
  64. // 表格列配置
  65. columns: [
  66. {
  67. columnKey: 'selection',
  68. type: 'selection',
  69. width: 45,
  70. align: 'center',
  71. selectable: (row, index) => {
  72. return !this.selectList.some((it) => row.id == it.id);
  73. },
  74. reserveSelection: true,
  75. },
  76. {
  77. columnKey: 'index',
  78. type: 'index',
  79. width: 45,
  80. align: 'center',
  81. reserveSelection: true
  82. },
  83. {
  84. prop: 'code',
  85. label: '编码'
  86. },
  87. {
  88. prop: 'name',
  89. label: '名称',
  90. showOverflowTooltip: true
  91. },
  92. {
  93. prop: 'brandNum',
  94. label: '牌号'
  95. },
  96. {
  97. prop: 'modelType',
  98. label: '型号',
  99. align: 'center',
  100. showOverflowTooltip: true
  101. },
  102. {
  103. prop: 'specification',
  104. label: '规格',
  105. align: 'center',
  106. showOverflowTooltip: true
  107. },
  108. {
  109. prop: 'measuringUnit',
  110. label: '计量单位',
  111. showOverflowTooltip: true,
  112. minWidth: 90
  113. },
  114. {
  115. prop: 'weightUnit',
  116. label: '重量单位',
  117. showOverflowTooltip: true,
  118. minWidth: 90
  119. },
  120. {
  121. prop: 'roughWeight',
  122. label: '毛重',
  123. showOverflowTooltip: true,
  124. minWidth: 90
  125. },
  126. {
  127. prop: 'netWeight',
  128. label: '净重',
  129. showOverflowTooltip: true,
  130. minWidth: 90
  131. },
  132. {
  133. prop: 'packingUnit',
  134. align: 'center',
  135. label: '包装单位',
  136. showOverflowTooltip: true
  137. },
  138. {
  139. prop: 'categoryLevelPath',
  140. label: '分类',
  141. align: 'center',
  142. showOverflowTooltip: true
  143. },
  144. {
  145. action: 'action',
  146. slot: 'action',
  147. align: 'center',
  148. label: '选择'
  149. }
  150. ],
  151. title: null,
  152. categoryLevelId: null,
  153. radio: null,
  154. idx: null,
  155. isCategory: true,
  156. current: {},
  157. treeList: [],
  158. treeLoading: false,
  159. defaultProps: {
  160. children: 'children',
  161. label: 'name'
  162. }
  163. };
  164. },
  165. watch: {},
  166. methods: {
  167. /* 表格数据源 */
  168. datasource({ page, where, limit }) {
  169. return getMaterialList({
  170. ...where,
  171. pageNum: page,
  172. size: limit,
  173. categoryLevelId: this.isCategory ? this.categoryLevelId : null
  174. });
  175. },
  176. handleNodeClick(data) {
  177. this.isCategory = true;
  178. this.categoryLevelId = data.id;
  179. this.$refs.table.reload({ pageNum: 1, where: {} });
  180. this.$refs.searchRef.reset2();
  181. },
  182. /* 刷新表格 */
  183. reload(where) {
  184. this.isCategory = false;
  185. this.$refs.table.reload({ pageNum: 1, where: where });
  186. },
  187. open(list) {
  188. this.selectList = list;
  189. this.getTreeData();
  190. this.visible = true;
  191. },
  192. async getTreeData() {
  193. try {
  194. this.treeLoading = true;
  195. const res = await getTreeByGroup({ type: 1 });
  196. this.treeLoading = false;
  197. if (res?.code === '0') {
  198. this.treeList = res.data;
  199. this.$nextTick(() => {
  200. // 默认高亮第一级树节点
  201. if (this.treeList[0]) {
  202. this.rootTreeId = this.treeList[0].id;
  203. this.$nextTick(() => {
  204. this.$refs.treeRef.setCurrentKey(this.treeList[0].id);
  205. });
  206. }
  207. });
  208. return this.treeList;
  209. }
  210. } catch (error) {}
  211. this.treeLoading = false;
  212. },
  213. handleClose() {
  214. this.visible = false;
  215. this.current = null;
  216. this.radio = '';
  217. },
  218. selected() {
  219. if (this.selection.length <= 0) {
  220. return this.$message.warning('请至少选择一条数据');
  221. }
  222. this.$emit('selection',this.selection);
  223. this.handleClose();
  224. }
  225. }
  226. };
  227. </script>
  228. <style lang="scss" scoped>
  229. .tree_col {
  230. border: 1px solid #eee;
  231. padding: 10px 0;
  232. box-sizing: border-box;
  233. height: 500px;
  234. overflow: auto;
  235. }
  236. .table_col {
  237. padding-left: 10px;
  238. ::v-deep .el-table th.el-table__cell {
  239. background: #f2f2f2;
  240. }
  241. }
  242. .pagination {
  243. text-align: right;
  244. padding: 10px 0;
  245. }
  246. .btns {
  247. text-align: center;
  248. padding: 10px 0;
  249. }
  250. .topsearch {
  251. margin-bottom: 15px;
  252. }
  253. </style>