EquipmentDialog.vue 5.0 KB

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