index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <BOMSearch @search="reload" :statusOpt="statusOpt" />
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. :datasource="datasource"
  9. class="dict-table"
  10. tool-class="ele-toolbar-actions"
  11. >
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <el-button type="primary" size="small" @click="handelEdit('新建')">新建</el-button>
  15. <el-button
  16. size="small"
  17. type="primary"
  18. icon="el-icon-refresh-left"
  19. class="ele-btn-icon"
  20. @click='refreshData'
  21. :loading="loading"
  22. >刷新</el-button>
  23. </template>
  24. <template v-slot:action="{ row }">
  25. <el-link type="primary" @click="handelDetail(row)">详情</el-link>
  26. <!-- <el-link type="primary" icon="el-icon-edit" @click="handelEdit('编辑')">编辑</el-link> -->
  27. </template>
  28. </ele-pro-table>
  29. </el-card>
  30. <ViewDialog ref="detailDialogRef" :statusOpt="statusOpt" />
  31. <EditDialog ref="editDialogRef" :statusOpt="statusOpt"></EditDialog>
  32. </div>
  33. </template>
  34. <script>
  35. import BOMSearch from './components/BOM-search.vue';
  36. import ViewDialog from './components/view-dialog.vue';
  37. import EditDialog from './components/edit-dialog.vue'
  38. import { getPage , syncBom } from '@/api/material/BOM';
  39. export default {
  40. name: 'SystemDictionary',
  41. components: { BOMSearch, ViewDialog, EditDialog },
  42. data () {
  43. return {
  44. // 表格列配置
  45. columns: [
  46. {
  47. label: '序号',
  48. columnKey: 'index',
  49. type: 'index',
  50. width: 55,
  51. align: 'center',
  52. showOverflowTooltip: true
  53. },
  54. {
  55. prop: 'code',
  56. label: 'BOM编码',
  57. showOverflowTooltip: true
  58. },
  59. {
  60. prop: 'name',
  61. label: 'BOM名称',
  62. showOverflowTooltip: true
  63. },
  64. {
  65. prop: 'categoryCode',
  66. label: '产品编码',
  67. showOverflowTooltip: true
  68. },
  69. {
  70. prop: 'categoryName',
  71. label: '产品名称',
  72. showOverflowTooltip: true
  73. },
  74. {
  75. prop: 'version',
  76. label: '版本'
  77. },
  78. {
  79. prop: 'status ',
  80. label: '状态',
  81. formatter: (row) => {
  82. return this.statusOpt[row.status];
  83. }
  84. },
  85. {
  86. prop: 'createUserName',
  87. label: '创建人',
  88. showOverflowTooltip: true
  89. },
  90. {
  91. prop: 'createTime',
  92. label: '创建日期',
  93. showOverflowTooltip: true
  94. },
  95. {
  96. action: 'action',
  97. slot: 'action',
  98. label: '操作'
  99. }
  100. ],
  101. statusOpt: {
  102. '-1': '草稿',
  103. 0: '已停用',
  104. 1: '已发布'
  105. },
  106. loading:false
  107. };
  108. },
  109. methods: {
  110. /* 表格数据源 */
  111. datasource ({ where, page, limit }) {
  112. return getPage({
  113. ...where,
  114. pageNum: page,
  115. size: limit
  116. });
  117. },
  118. handelDetail (row) {
  119. this.$refs.detailDialogRef.open(row);
  120. },
  121. /* 刷新表格 */
  122. reload (where) {
  123. this.$refs.table.reload({ where });
  124. },
  125. /* 显示编辑 */
  126. handelEdit (row) {
  127. this.$refs.editDialogRef.open(row);
  128. },
  129. /* 删除 */
  130. remove () {
  131. this.$confirm('确定要删除选中的字典吗?', '提示', {
  132. type: 'warning'
  133. })
  134. .then(() => {
  135. if (this.$refs.dictData.selection.length == 0) {
  136. this.$message({
  137. message: '当前未选择数据',
  138. type: 'error'
  139. });
  140. return;
  141. }
  142. let ids = this.$refs.dictData.selection.map((item) => item.id);
  143. const loading = this.$loading({ lock: true });
  144. removeDictionary(ids, true)
  145. .then((msg) => {
  146. loading.close();
  147. this.$message.success(msg);
  148. this.reload();
  149. })
  150. .catch((e) => {
  151. loading.close();
  152. // this.$message.error(e.message);
  153. });
  154. })
  155. .catch(() => {});
  156. },
  157. // 刷新数据
  158. refreshData(){
  159. this.loading = true;
  160. syncBom().then(res=>{
  161. if(res=='0'){
  162. this.loading = false;
  163. this.$message.success('数据刷新成功!')
  164. this.reload()
  165. }
  166. })
  167. .catch((e) => {
  168. this.loading = false;
  169. });
  170. }
  171. }
  172. };
  173. </script>
  174. <style lang="scss" scoped></style>