product-list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <el-dialog title="选择产品" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
  3. top="5vh"
  4. :close-on-press-escape="false" append-to-body width="80%">
  5. <el-card shadow="never">
  6. <searchProduct @search="reload"></searchProduct>
  7. <ele-split-layout width="244px" allow-collapse :right-style="{ overflow: 'hidden' }">
  8. <div class="ele-border-lighter split-layout-right-content">
  9. <productTree @handleNodeClick="handleNodeClick" :isFirstRefreshTable="false" ref="treeList"/>
  10. </div>
  11. <!-- 表格 -->
  12. <template v-slot:content>
  13. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" row-key="id"
  14. height="calc(100vh - 350px)" class="dict-table" @cell-click="cellClick">
  15. <!-- 表头工具栏 -->
  16. <template v-slot:action="{ row }">
  17. <el-radio class="radio" v-model="radio" :label="row.code"><i></i></el-radio>
  18. </template>
  19. </ele-pro-table>
  20. </template>
  21. </ele-split-layout>
  22. </el-card>
  23. <div class="btns">
  24. <el-button type="primary" size="small" @click="selected">选择</el-button>
  25. <el-button size="small" @click="handleClose">关闭</el-button>
  26. </div>
  27. </el-dialog>
  28. </template>
  29. <script>
  30. import {getProductList} from '@/api/saleManage/quotation';
  31. import searchProduct from './searchProduct.vue';
  32. import productTree from '@/components/productTree';
  33. export default {
  34. components: {
  35. productTree,
  36. searchProduct
  37. },
  38. data() {
  39. return {
  40. visible: false,
  41. currentIndex: null,
  42. columns: [
  43. {
  44. action: 'action',
  45. slot: 'action',
  46. align: 'center',
  47. label: '选择'
  48. },
  49. {
  50. columnKey: 'index',
  51. type: 'index',
  52. width: 50,
  53. align: 'center',
  54. showOverflowTooltip: true,
  55. label: '序号'
  56. },
  57. {
  58. prop: 'code',
  59. label: '编码',
  60. align: 'center',
  61. showOverflowTooltip: true,
  62. minWidth: 110
  63. },
  64. {
  65. prop: 'name',
  66. label: '名称',
  67. align: 'center',
  68. showOverflowTooltip: true,
  69. minWidth: 110
  70. },
  71. {
  72. prop: 'brandNum',
  73. align: 'center',
  74. label: '牌号',
  75. showOverflowTooltip: true
  76. },
  77. {
  78. prop: 'modelType',
  79. label: '型号',
  80. align: 'center',
  81. showOverflowTooltip: true
  82. },
  83. {
  84. prop: 'specification',
  85. label: '规格',
  86. align: 'center',
  87. showOverflowTooltip: true
  88. },
  89. {
  90. prop: 'measuringUnit',
  91. label: '计量单位',
  92. showOverflowTooltip: true,
  93. minWidth: 90
  94. },
  95. {
  96. prop: 'weightUnit',
  97. label: '重量单位',
  98. showOverflowTooltip: true,
  99. minWidth: 90
  100. },
  101. {
  102. prop: 'roughWeight',
  103. label: '毛重',
  104. showOverflowTooltip: true,
  105. minWidth: 90
  106. },
  107. {
  108. prop: 'netWeight',
  109. label: '净重',
  110. showOverflowTooltip: true,
  111. minWidth: 90
  112. },
  113. {
  114. prop: 'packingUnit',
  115. align: 'center',
  116. label: '包装单位',
  117. showOverflowTooltip: true
  118. },
  119. {
  120. prop: 'categoryLevelPath',
  121. label: '分类',
  122. align: 'center',
  123. showOverflowTooltip: true
  124. }
  125. ],
  126. radio: null,
  127. }
  128. },
  129. watch: {},
  130. methods: {
  131. open(item, currentIndex) {
  132. this.currentIndex = currentIndex
  133. if (item && item.id) {
  134. this.radio = item.id
  135. }
  136. this.visible = true
  137. },
  138. /* 表格数据源 */
  139. datasource({page, limit, where, order}) {
  140. return getProductList({
  141. pageNum: page,
  142. size: limit,
  143. ...where
  144. });
  145. },
  146. /* 刷新表格 */
  147. reload(where) {
  148. this.$refs.table.reload({pageNum: 1, where: where});
  149. },
  150. handleNodeClick(data, node) {
  151. this.curNodeData = data;
  152. this.reload({categoryLevelId: data.id});
  153. },
  154. // 单击获取id
  155. cellClick(row) {
  156. this.current = row
  157. this.radio = row.id
  158. },
  159. handleClose() {
  160. this.visible = false
  161. this.current = null
  162. this.radio = ''
  163. },
  164. selected() {
  165. if (!this.current) {
  166. return this.$message.warning('请至少选择一条数据')
  167. }
  168. this.$emit('changeParent', this.current, this.currentIndex)
  169. this.handleClose()
  170. },
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .tree_col {
  176. border: 1px solid #eee;
  177. padding: 10px 0;
  178. box-sizing: border-box;
  179. height: 500px;
  180. overflow: auto;
  181. }
  182. .table_col {
  183. padding-left: 10px;
  184. ::v-deep .el-table th.el-table__cell {
  185. background: #f2f2f2;
  186. }
  187. }
  188. .pagination {
  189. text-align: right;
  190. padding: 10px 0;
  191. }
  192. .btns {
  193. text-align: center;
  194. padding: 10px 0;
  195. }
  196. .topsearch {
  197. margin-bottom: 15px;
  198. }
  199. </style>