detailedList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. <ele-pro-table
  10. ref="table"
  11. :columns="columns"
  12. :datasource="datasource"
  13. :initLoad="false"
  14. class="dict-table"
  15. tool-class="ele-toolbar-actions"
  16. >
  17. <template v-slot:toolbar>
  18. <div class="toolbar_box">
  19. <div
  20. ><span>基本数量</span>
  21. <el-input placeholder="请输入" v-model.number="attributeData.baseCount">
  22. </el-input>
  23. <DictSelection dictName="计量单位" v-model="attributeData.unit"
  24. /></div>
  25. </div>
  26. </template>
  27. <!-- 表头工具栏 -->
  28. <template v-slot:action="{ row }">
  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-card>
  39. </div>
  40. </template>
  41. <script>
  42. import BOMSearch from './BOM-search.vue';
  43. import { getBomPageCategoryId, startAndStop } from '@/api/material/BOM';
  44. export default {
  45. name: 'SystemDictionary',
  46. components: { BOMSearch },
  47. data() {
  48. return {
  49. // 表格列配置
  50. columns: [
  51. {
  52. label: '序号',
  53. columnKey: 'index',
  54. type: 'index',
  55. width: 55,
  56. align: 'center',
  57. showOverflowTooltip: true
  58. },
  59. {
  60. prop: 'code',
  61. label: 'BOM编码',
  62. showOverflowTooltip: true
  63. },
  64. {
  65. prop: 'name',
  66. label: 'BOM名称',
  67. showOverflowTooltip: true
  68. },
  69. {
  70. prop: 'categoryCode',
  71. label: '产品编码',
  72. showOverflowTooltip: true
  73. },
  74. {
  75. prop: 'categoryName',
  76. label: '产品名称',
  77. showOverflowTooltip: true
  78. },
  79. {
  80. prop: 'dosage',
  81. label: '用量',
  82. showOverflowTooltip: true
  83. },
  84. {
  85. prop: 'measuringUnit',
  86. label: '计量单位',
  87. showOverflowTooltip: true
  88. },
  89. {
  90. prop: 'versions',
  91. label: '版本'
  92. },
  93. {
  94. prop: 'status ',
  95. label: '状态',
  96. formatter: (row) => {
  97. return this.statusOpt[+row.status];
  98. }
  99. },
  100. {
  101. prop: 'createName',
  102. label: '创建人',
  103. showOverflowTooltip: true
  104. },
  105. {
  106. prop: 'createTime',
  107. label: '创建日期',
  108. showOverflowTooltip: true
  109. },
  110. {
  111. action: 'action',
  112. slot: 'action',
  113. label: '操作'
  114. }
  115. ],
  116. statusOpt: {
  117. '': '全部',
  118. 0: '已停用',
  119. 1: '已发布'
  120. },
  121. loading: false,
  122. loadingInstance: null,
  123. where: {},
  124. attrObj: {}
  125. };
  126. },
  127. mounted() {},
  128. props: {
  129. attributeData: {
  130. type: Object,
  131. default: {}
  132. }
  133. },
  134. watch: {
  135. attributeData(val) {
  136. this.attrObj = val;
  137. this.$refs.table.setData([]);
  138. this.$nextTick(() => {
  139. this.$refs.table.reload({
  140. pageNum: 1
  141. });
  142. });
  143. }
  144. },
  145. methods: {
  146. /* 启用关闭BOM */
  147. openBom(row, boolean) {
  148. this.loadingInstance = this.$loading({
  149. lock: true,
  150. text: boolean ? '启用中...' : '关闭中...',
  151. background: 'rgba(0, 0, 0, 0.7)'
  152. });
  153. startAndStop({ id: row.id, status: row.status }).then(() => {
  154. this.$message.success('操作成功');
  155. this.loadingInstance.close();
  156. });
  157. setTimeout(() => {}, 2000);
  158. },
  159. /* 表格数据源 */
  160. datasource({ where, page, limit }) {
  161. if (!this.attrObj.id) {
  162. return false;
  163. }
  164. return getBomPageCategoryId({
  165. ...where,
  166. pageNum: page,
  167. size: limit,
  168. id: this.attrObj.id,
  169. bomType: this.attrObj.bomType
  170. });
  171. },
  172. /* 刷新表格 */
  173. reload(where) {
  174. this.$refs.table.reload({ where });
  175. }
  176. }
  177. };
  178. </script>
  179. <style lang="scss" scoped>
  180. .ele-body {
  181. height: 100%;
  182. ::v-deep .el-card {
  183. height: 100%;
  184. .el-card__body {
  185. height: 100%;
  186. display: flex;
  187. flex-direction: column;
  188. .dict-table {
  189. flex: 1;
  190. overflow: hidden;
  191. display: flex;
  192. flex-direction: column;
  193. .el-table {
  194. flex: 1;
  195. overflow-y: auto;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. .toolbar_box {
  202. float: right;
  203. margin-right: 10px;
  204. > div {
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. > span {
  209. width: 150px;
  210. }
  211. > div {
  212. margin-left: 10px;
  213. }
  214. }
  215. }
  216. </style>