index-data.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :need-page="true" :selection.sync="selection"
  5. height="calc(100vh - 412px)" full-height="calc(100vh - 116px)" tool-class="ele-toolbar-form"
  6. cache-key="systemDictDataTable">
  7. <!-- 表头工具栏 -->
  8. <template v-slot:toolbar>
  9. <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit({}, 2)">
  10. 新建
  11. </el-button>
  12. </template>
  13. <template v-slot:action="{ row }">
  14. <el-link type="primary" :underline="false" icon="el-icon-copy-document" @click="openEdit(row, 1)">
  15. 复制
  16. </el-link>
  17. <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit(row, 0)">
  18. 修改
  19. </el-link>
  20. <el-popconfirm class="ele-action" title="确定要删除此物料吗?" @confirm="remove(row)">
  21. <template v-slot:reference>
  22. <el-link type="danger" :underline="false" icon="el-icon-delete">
  23. 删除
  24. </el-link>
  25. </template>
  26. </el-popconfirm>
  27. <el-link v-if="row.isProduct == 1" type="primary" :underline="false" @click="openMaterial(row)">
  28. 物料BOM
  29. </el-link>
  30. </template>
  31. </ele-pro-table>
  32. <!-- 编辑弹窗 -->
  33. <!-- <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
  34. <!-- 选择物料 -->
  35. <MaterialModal :visible.sync="materialEdit" :data="current" ref="materialRefs"></MaterialModal>
  36. </div>
  37. </template>
  38. <script>
  39. import { getMaterialList, removeMaterial } from '@/api/material/manage.js';
  40. import MaterialModal from './MaterialModal.vue'
  41. export default {
  42. components: {
  43. MaterialModal
  44. },
  45. props: {
  46. // 物料组id
  47. currentId: [Number, String],
  48. data: Object,
  49. rootId: [Number, String],
  50. },
  51. data() {
  52. return {
  53. // 表格列配置
  54. columns: [
  55. {
  56. columnKey: 'index',
  57. type: 'index',
  58. width: 50,
  59. align: 'center',
  60. showOverflowTooltip: true,
  61. label: '序号'
  62. },
  63. {
  64. prop: 'code',
  65. label: '编码',
  66. align: 'center',
  67. showOverflowTooltip: true,
  68. minWidth: 110
  69. },
  70. {
  71. prop: 'name',
  72. label: '名称',
  73. align: 'center',
  74. showOverflowTooltip: true,
  75. minWidth: 110
  76. },
  77. {
  78. prop: 'brandNum',
  79. align: 'center',
  80. label: '牌号',
  81. showOverflowTooltip: true
  82. },
  83. {
  84. prop: 'modelType',
  85. label: '型号',
  86. align: 'center',
  87. showOverflowTooltip: true
  88. },
  89. {
  90. prop: 'specification',
  91. label: '规格',
  92. align: 'center',
  93. showOverflowTooltip: true
  94. },
  95. {
  96. prop: 'measuringUnit',
  97. label: '计量单位',
  98. showOverflowTooltip: true,
  99. minWidth: 90
  100. },
  101. {
  102. prop: 'weightUnit',
  103. label: '重量单位',
  104. showOverflowTooltip: true,
  105. minWidth: 90
  106. },
  107. {
  108. prop: 'roughWeight',
  109. label: '毛重',
  110. showOverflowTooltip: true,
  111. minWidth: 90
  112. },
  113. {
  114. prop: 'netWeight',
  115. label: '净重',
  116. showOverflowTooltip: true,
  117. minWidth: 90
  118. },
  119. {
  120. prop: 'packingUnit',
  121. align: 'center',
  122. label: '包装单位',
  123. showOverflowTooltip: true
  124. },
  125. {
  126. prop: 'categoryLevelPath',
  127. label: '分类',
  128. align: 'center',
  129. showOverflowTooltip: true
  130. },
  131. {
  132. columnKey: 'action',
  133. label: '操作',
  134. width: 200,
  135. align: 'center',
  136. resizable: false,
  137. slot: 'action',
  138. fixed: 'right'
  139. }
  140. ],
  141. // 表格选中数据
  142. selection: [],
  143. // 是否显示编辑弹窗
  144. showEdit: false,
  145. id: null,
  146. materialEdit: false,
  147. current: null,
  148. };
  149. },
  150. methods: {
  151. /* 表格数据源 */
  152. datasource({ page, limit, where, order }) {
  153. return getMaterialList({
  154. pageNum: page,
  155. size: limit,
  156. ...where,
  157. categoryLevelId: this.currentId
  158. });
  159. },
  160. /* 刷新表格 */
  161. reload(where) {
  162. this.$refs.table.reload({
  163. page: 1,
  164. where: where,
  165. categoryLevelId: this.currentId
  166. });
  167. },
  168. /* 显示编辑 */
  169. openEdit(row, status) {
  170. this.$router.push({
  171. path: '/material/product/detail',
  172. query: {
  173. id: row.id ? row.id : null,
  174. status: status,
  175. rootId: this.rootId
  176. }
  177. });
  178. },
  179. /* 删除 */
  180. remove(row) {
  181. const loading = this.$loading({ lock: true });
  182. removeMaterial(row.id)
  183. .then((msg) => {
  184. loading.close();
  185. this.$message.success('删除' + msg);
  186. this.reload();
  187. })
  188. .catch((e) => {
  189. loading.close();
  190. // this.$message.error(e.message);
  191. });
  192. },
  193. openMaterial(row) {
  194. this.current = row;
  195. this.materialEdit = true;
  196. this.$refs.materialRefs.$refs.form &&
  197. this.$refs.materialRefs.$refs.form.clearValidate();
  198. }
  199. },
  200. watch: {
  201. // 监听物料组id变化
  202. currentId() {
  203. this.reload();
  204. }
  205. }
  206. };
  207. </script>