index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <BOMSearch
  5. @search="reload"
  6. :statusOpt="statusOpt"
  7. :categoryCode="where.categoryCode"
  8. />
  9. <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
  10. <el-tab-pane label="PBOM" name="1"> </el-tab-pane>
  11. <el-tab-pane label="MBOM" name="2"> </el-tab-pane>
  12. <el-tab-pane label="ABOM" name="3"> </el-tab-pane>
  13. <ele-pro-table
  14. ref="table"
  15. :columns="columns"
  16. :datasource="datasource"
  17. :initLoad="false"
  18. class="dict-table"
  19. tool-class="ele-toolbar-actions"
  20. >
  21. <!-- 表头工具栏 -->
  22. <template v-slot:action="{ row }">
  23. <el-link
  24. style="margin-right: 20px"
  25. type="primary"
  26. @click="handelDetail(row)"
  27. >详情</el-link
  28. >
  29. <el-switch
  30. :active-value="'1'"
  31. :inactive-value="'0'"
  32. @change="openBom(row, $event)"
  33. v-model="row.status"
  34. >
  35. </el-switch>
  36. </template>
  37. </ele-pro-table>
  38. </el-tabs>
  39. </el-card>
  40. </div>
  41. </template>
  42. <script>
  43. import BOMSearch from '../materialBOM/components/BOM-search.vue';
  44. import { getBomPageList, startAndStop } from '@/api/material/BOM';
  45. export default {
  46. name: 'SystemDictionary',
  47. components: { BOMSearch },
  48. data() {
  49. return {
  50. // 表格列配置
  51. columns: [
  52. {
  53. label: '序号',
  54. columnKey: 'index',
  55. type: 'index',
  56. width: 55,
  57. align: 'center',
  58. showOverflowTooltip: true
  59. },
  60. {
  61. prop: 'code',
  62. label: 'BOM编码',
  63. showOverflowTooltip: true
  64. },
  65. {
  66. prop: 'name',
  67. label: 'BOM名称',
  68. showOverflowTooltip: true
  69. },
  70. {
  71. prop: 'categoryCode',
  72. label: '产品编码',
  73. showOverflowTooltip: true
  74. },
  75. {
  76. prop: 'categoryName',
  77. label: '产品名称',
  78. showOverflowTooltip: true
  79. },
  80. {
  81. prop: 'versions',
  82. label: '版本'
  83. },
  84. {
  85. prop: 'status ',
  86. label: '状态',
  87. formatter: (row) => {
  88. return this.statusOpt[+row.status];
  89. }
  90. },
  91. {
  92. prop: 'createName',
  93. label: '创建人',
  94. showOverflowTooltip: true
  95. },
  96. {
  97. prop: 'createTime',
  98. label: '创建日期',
  99. showOverflowTooltip: true
  100. },
  101. {
  102. action: 'action',
  103. slot: 'action',
  104. label: '操作'
  105. }
  106. ],
  107. statusOpt: {
  108. '': '全部',
  109. 0: '已停用',
  110. 1: '已发布'
  111. },
  112. loading: false,
  113. loadingInstance: null,
  114. where: {},
  115. activeName: "1"
  116. };
  117. },
  118. mounted() {
  119. this.initData();
  120. },
  121. activated() {
  122. this.initData();
  123. },
  124. methods: {
  125. initData() {
  126. let { categoryId, code } = this.$route.query;
  127. if (categoryId && code) {
  128. this.where.categoryCode = code;
  129. this.where.categoryId = categoryId;
  130. getBomPageList({
  131. status: 1,
  132. categoryCode: this.where.categoryCode,
  133. pageNum: 1,
  134. size: 10
  135. }).then((data) => {
  136. if (data.count > 1) {
  137. this.$refs.table.setData(data.list || []);
  138. } else {
  139. this.handelDetail(
  140. data.list[0]
  141. ? data.list[0]
  142. : { categoryId: this.where.categoryId },
  143. true
  144. );
  145. }
  146. });
  147. } else {
  148. this.reload();
  149. }
  150. },
  151. /* 启用关闭BOM */
  152. openBom(row, boolean) {
  153. this.loadingInstance = this.$loading({
  154. lock: true,
  155. text: boolean ? '启用中...' : '关闭中...',
  156. background: 'rgba(0, 0, 0, 0.7)'
  157. });
  158. startAndStop({ id: row.id, status: row.status }).then(() => {
  159. this.$message.success('操作成功');
  160. this.loadingInstance.close();
  161. });
  162. setTimeout(() => {}, 2000);
  163. },
  164. /* 表格数据源 */
  165. datasource({ where, page, limit }) {
  166. return getBomPageList({
  167. ...where,
  168. bomType: Number(this.activeName),
  169. pageNum: page,
  170. size: limit
  171. });
  172. },
  173. handelDetail(row, noBack) {
  174. this.$router.push({
  175. path: '/material/BOMmanage/details',
  176. query: { versions: row.versions, categoryId: row.categoryId, noBack }
  177. });
  178. },
  179. /* 刷新表格 */
  180. reload(where) {
  181. this.$refs.table.reload({ where });
  182. },
  183. /* 显示编辑 */
  184. handelEdit(type, row) {
  185. this.$refs.editDialogRef.open(type, row);
  186. },
  187. /* 删除 */
  188. remove() {
  189. this.$confirm('确定要删除选中的字典吗?', '提示', {
  190. type: 'warning'
  191. })
  192. .then(() => {
  193. if (this.$refs.dictData.selection.length == 0) {
  194. this.$message({
  195. message: '当前未选择数据',
  196. type: 'error'
  197. });
  198. return;
  199. }
  200. let ids = this.$refs.dictData.selection.map((item) => item.id);
  201. const loading = this.$loading({ lock: true });
  202. removeDictionary(ids, true)
  203. .then((msg) => {
  204. loading.close();
  205. this.$message.success(msg);
  206. this.reload();
  207. })
  208. .catch((e) => {
  209. loading.close();
  210. // this.$message.error(e.message);
  211. });
  212. })
  213. .catch(() => {});
  214. },
  215. // 刷新数据
  216. refreshData() {
  217. this.loading = true;
  218. syncBom()
  219. .then((res) => {
  220. if (res == '0') {
  221. this.loading = false;
  222. this.$message.success('数据刷新成功!');
  223. this.reload();
  224. }
  225. })
  226. .catch((e) => {
  227. this.loading = false;
  228. });
  229. },
  230. handleClick(tab) {
  231. this.activeName = tab.name
  232. getBomPageList({
  233. pageNum: 1,
  234. size: 10,
  235. bomType: Number(this.activeName)
  236. }).then((data) => {
  237. this.$refs.table.setData(data.list || []);
  238. });
  239. }
  240. }
  241. };
  242. </script>
  243. <style lang="scss" scoped>
  244. .ele-body {
  245. height: 100%;
  246. ::v-deep .el-card {
  247. height: 100%;
  248. .el-card__body {
  249. height: 100%;
  250. display: flex;
  251. flex-direction: column;
  252. .dict-table {
  253. flex: 1;
  254. overflow: hidden;
  255. display: flex;
  256. flex-direction: column;
  257. .el-table {
  258. flex: 1;
  259. overflow-y: auto;
  260. }
  261. }
  262. }
  263. }
  264. }
  265. </style>