product-list.vue 5.5 KB

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