index.vue 8.5 KB

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