EquipmentDialog.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <el-dialog
  3. title="选择产品"
  4. :visible.sync="equipmentdialog"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. append-to-body
  9. width="60%"
  10. >
  11. <div>
  12. <el-row>
  13. <el-col :span="24" class="topsearch">
  14. <el-form>
  15. <el-row>
  16. <el-col :span="6">
  17. <el-input
  18. v-model="code"
  19. placeholder="请输入产品编码"
  20. size="small"
  21. ></el-input>
  22. </el-col>
  23. <el-col :span="6" style="margin-left: 10px">
  24. <el-button type="primary" size="small" @click="reload"
  25. >搜索</el-button
  26. >
  27. <el-button size="small" @click="reset">重置</el-button>
  28. </el-col>
  29. </el-row>
  30. </el-form>
  31. </el-col>
  32. <el-col :span="6" class="tree_col">
  33. <AssetTree
  34. @handleNodeClick="handleNodeClick"
  35. id="9"
  36. :paramsType="'type'"
  37. ref="treeList"
  38. />
  39. </el-col>
  40. <el-col :span="18" class="table_col">
  41. <ele-pro-table
  42. ref="equiTable"
  43. :columns="columns"
  44. :datasource="datasource"
  45. :selection.sync="selection"
  46. cache-key="systemRoleTable"
  47. row-key="id"
  48. @done="setSelect"
  49. >
  50. </ele-pro-table>
  51. </el-col>
  52. </el-row>
  53. </div>
  54. <div class="btns">
  55. <el-button type="primary" size="small" @click="selected">选择</el-button>
  56. <el-button size="small" @click="handleClose">关闭</el-button>
  57. </div>
  58. </el-dialog>
  59. </template>
  60. <script>
  61. import AssetTree from '@/components/AssetTree';
  62. import { getList } from '@/api/classifyManage/itemInformation';
  63. export default {
  64. components: {
  65. AssetTree
  66. },
  67. props: {
  68. selectList: Array
  69. },
  70. data () {
  71. return {
  72. equipmentdialog: false,
  73. columns: [
  74. {
  75. width: 45,
  76. type: 'selection',
  77. columnKey: 'selection',
  78. align: 'center',
  79. reserveSelection: true
  80. },
  81. {
  82. columnKey: 'index',
  83. label: '序号',
  84. type: 'index',
  85. width: 55,
  86. align: 'center',
  87. showOverflowTooltip: true
  88. },
  89. {
  90. prop: 'code',
  91. label: '物品编码',
  92. align: 'center',
  93. showOverflowTooltip: true,
  94. minWidth: 110,
  95. slot: 'code'
  96. },
  97. {
  98. prop: 'name',
  99. label: '物品名称',
  100. align: 'center',
  101. showOverflowTooltip: true,
  102. minWidth: 110
  103. },
  104. {
  105. prop: 'brandNum',
  106. label: '牌号',
  107. align: 'center',
  108. showOverflowTooltip: true,
  109. minWidth: 110
  110. },
  111. {
  112. prop: 'modelType',
  113. label: '型号',
  114. align: 'center',
  115. showOverflowTooltip: true,
  116. minWidth: 110
  117. }
  118. ],
  119. tableList: [],
  120. categoryLevelId: null,
  121. code: null,
  122. selection: []
  123. };
  124. },
  125. watch: {},
  126. methods: {
  127. async datasource ({ page, limit }) {
  128. const params = {
  129. code: this.code,
  130. pageNum: page,
  131. size: limit,
  132. categoryLevelId: this.categoryLevelId,
  133. isProduct:true
  134. };
  135. const data = await getList(params);
  136. this.tableList = data.list;
  137. return data;
  138. },
  139. open () {
  140. this.equipmentdialog = true;
  141. this.setSelect();
  142. },
  143. handleNodeClick (data) {
  144. this.categoryLevelId = data.id;
  145. this.reload();
  146. },
  147. reload () {
  148. this.$refs.equiTable.reload();
  149. },
  150. handleClose () {
  151. this.equipmentdialog = false;
  152. this.$refs.equiTable.clearSelection();
  153. },
  154. reset () {
  155. this.code = null;
  156. this.reload();
  157. },
  158. // 设置选中
  159. setSelect () {
  160. this.$nextTick(() => {
  161. this.tableList.forEach((row) => {
  162. this.selectList.forEach((selected) => {
  163. if (selected.productCode === row.code) {
  164. this.$refs.equiTable.toggleRowSelection(row, true);
  165. }
  166. });
  167. });
  168. });
  169. },
  170. // 选择
  171. selected () {
  172. this.$emit('choose', this.selection);
  173. this.handleClose();
  174. }
  175. }
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. .tree_col {
  180. border: 1px solid #eee;
  181. padding: 10px 0;
  182. box-sizing: border-box;
  183. height: 530px;
  184. overflow: auto;
  185. }
  186. .table_col {
  187. padding-left: 10px;
  188. ::v-deep .el-table th.el-table__cell {
  189. background: #f2f2f2;
  190. }
  191. }
  192. .pagination {
  193. text-align: right;
  194. padding: 10px 0;
  195. }
  196. .btns {
  197. text-align: center;
  198. padding: 10px 0;
  199. }
  200. .topsearch {
  201. margin-bottom: 15px;
  202. }
  203. </style>