MaterialAdd.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="visible"
  5. :before-close="handleClose"
  6. class="productModal_dialog"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="90%"
  11. >
  12. <el-card shadow="never">
  13. <ele-split-layout
  14. width="244px"
  15. allow-collapse
  16. :right-style="{ overflow: 'hidden' }"
  17. >
  18. <div class="ele-border-lighter split-layout-right-content">
  19. <el-tree
  20. :data="treeList"
  21. :props="defaultProps"
  22. ref="treeRef"
  23. :expand-on-click-node="false"
  24. :default-expanded-keys="categoryId ? [categoryId] : []"
  25. :highlight-current="true"
  26. node-key="id"
  27. @node-click="handleNodeClick"
  28. ></el-tree>
  29. </div>
  30. <!-- 数据表格 -->
  31. <template v-slot:content>
  32. <ProductSearch @search="reload" ref="searchRef" />
  33. <ele-pro-table
  34. height="400"
  35. ref="table"
  36. :columns="columns"
  37. :datasource="datasource"
  38. :current.sync="current"
  39. highlight-current-row
  40. row-key="id"
  41. :initLoad="false"
  42. >
  43. <template v-slot:modelType="{ row }">
  44. <span>{{ row.category.modelType }}</span>
  45. </template>
  46. <template v-slot:specification="{ row }">
  47. <span>{{ row.category.specification }}</span>
  48. </template>
  49. <template v-slot:pathName="{ row }">
  50. <span>{{ row.position[0] && row.position[0].pathName }}</span>
  51. </template>
  52. </ele-pro-table>
  53. </template>
  54. </ele-split-layout>
  55. </el-card>
  56. <div class="rx-sc">
  57. <el-button type="primary" size="small" @click="selected">选择</el-button>
  58. <el-button size="small" @click="handleClose">关闭</el-button>
  59. </div>
  60. </el-dialog>
  61. </template>
  62. <script>
  63. import ProductSearch from '@/views/maintenance/components/product-search.vue';
  64. import { getAssetList } from '@/api/ruleManagement/plan';
  65. import { getTreeByPid, getTreeByGroup } from '@/api/classifyManage';
  66. export default {
  67. data() {
  68. return {
  69. ruleIdListIndex: 0,
  70. visible: false,
  71. title: '选择设备',
  72. categoryLevelId: null,
  73. categoryId: 1,
  74. treeList: [],
  75. treeLoading: false,
  76. defaultProps: {
  77. children: 'children',
  78. label: 'name'
  79. },
  80. type: null,
  81. // 表格列配置
  82. columns: [
  83. {
  84. label: '设备名称',
  85. prop: 'name'
  86. },
  87. {
  88. label: '编号',
  89. prop: 'codeNumber'
  90. },
  91. {
  92. label: '固资编码',
  93. prop: 'fixCode'
  94. },
  95. {
  96. label: '使用人',
  97. prop: 'usePerson'
  98. },
  99. {
  100. label: '使用岗位',
  101. prop: 'postName'
  102. },
  103. {
  104. label: '负责人',
  105. prop: 'chargePerson'
  106. },
  107. {
  108. label: '有效开始时间',
  109. prop: 'startTime'
  110. },
  111. {
  112. label: '有效结束时间',
  113. prop: 'endTime'
  114. },
  115. {
  116. label: '型号',
  117. prop: 'modelType',
  118. slot: 'modelType'
  119. },
  120. {
  121. label: '规格',
  122. prop: 'specification',
  123. slot: 'specification'
  124. },
  125. {
  126. label: '设备位置',
  127. prop: 'pathName',
  128. slot: 'pathName'
  129. }
  130. ],
  131. // 表格选中数据
  132. current: {}
  133. };
  134. },
  135. components: {
  136. ProductSearch
  137. },
  138. methods: {
  139. /* 表格数据源 */
  140. async datasource({ page, limit, where }) {
  141. const res = await getAssetList({
  142. ...where,
  143. pageNum: page,
  144. size: limit,
  145. categoryLevelId: this.categoryLevelId,
  146. rootCategoryLevelId: this.rootId
  147. });
  148. console.log('res---------', res);
  149. this.categoryId = res.list[0]?.categoryId;
  150. return res;
  151. },
  152. open() {
  153. this.visible = true;
  154. this.getTreeData();
  155. },
  156. async getTreeData() {
  157. try {
  158. this.treeLoading = true;
  159. const res = await getTreeByGroup({ type: 4 });
  160. console.log('res---treeList----------', res);
  161. this.treeLoading = false;
  162. if (res?.code === '0') {
  163. this.treeList = res.data;
  164. return this.treeList;
  165. }
  166. } catch (error) {
  167. console.log(error);
  168. }
  169. this.treeLoading = false;
  170. },
  171. handleNodeClick(data) {
  172. this.rootId = data.rootCategoryLevelId;
  173. this.categoryLevelId = data.id;
  174. this.$refs.table.reload({ pageNum: 1, where: {} });
  175. },
  176. /* 刷新表格 */
  177. reload(where) {
  178. if (this.rootId && this.categoryLevelId) {
  179. this.$refs.table.reload({ page: 1, where: where });
  180. } else {
  181. this.$message.error('请选择设备');
  182. }
  183. },
  184. handleClose() {
  185. this.visible = false;
  186. },
  187. selected() {
  188. if (!this.current.id) {
  189. this.$message.error('请至少选择一条数据');
  190. return;
  191. }
  192. this.$emit('chooseEquipment', this.current);
  193. this.handleClose();
  194. }
  195. }
  196. };
  197. </script>
  198. <style lang="scss" scoped>
  199. .productModal_dialog {
  200. overflow: hidden;
  201. ::v-deep .el-dialog {
  202. margin: 50px auto !important;
  203. height: 90%;
  204. overflow: hidden;
  205. .el-dialog__body {
  206. position: absolute;
  207. left: 0;
  208. top: 54px;
  209. bottom: 0;
  210. right: 0;
  211. padding: 0;
  212. z-index: 1;
  213. overflow: hidden;
  214. overflow-y: auto;
  215. // 下边设置字体,我的需求是黑底白字
  216. color: #ffffff;
  217. line-height: 30px;
  218. padding: 0 15px;
  219. display: flex;
  220. flex-direction: column;
  221. > div {
  222. flex: 1;
  223. .el-card__body {
  224. height: 100%;
  225. display: flex;
  226. flex-direction: column;
  227. box-sizing: border-box;
  228. > div {
  229. flex: 1;
  230. .ele-split-panel-body {
  231. display: flex;
  232. flex-direction: column;
  233. > div {
  234. height: 100%;
  235. display: flex;
  236. flex-direction: column;
  237. .el-table {
  238. flex: 1 0 auto;
  239. height: 0;
  240. overflow: auto;
  241. }
  242. }
  243. }
  244. }
  245. }
  246. }
  247. .rx-sc {
  248. flex: 0 0 50px;
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. }
  253. }
  254. }
  255. }
  256. ::v-deep {
  257. .el-checkbox__input.is-disabled .el-checkbox__inner {
  258. background-color: #c1c1c1 !important;
  259. }
  260. }
  261. .ml60 {
  262. margin-left: 60px;
  263. }
  264. </style>