standardOutput.vue 6.5 KB

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