selectEquipmentList.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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="70%"
  11. >
  12. <el-card shadow="never">
  13. <searchProduct @search="reload"></searchProduct>
  14. <ele-pro-table
  15. ref="table"
  16. :columns="columns"
  17. :datasource="datasource"
  18. row-key="id"
  19. height="calc(100vh - 480px)"
  20. class="dict-table"
  21. @cell-click="cellClick"
  22. :selection.sync="selection"
  23. >
  24. <!-- 表头工具栏 -->
  25. <template v-slot:action="{ row }">
  26. <el-radio class="radio" v-model="radio" :label="row.code"
  27. ><i></i
  28. ></el-radio>
  29. </template>
  30. </ele-pro-table>
  31. </el-card>
  32. <div slot="footer">
  33. <el-button type="primary" size="small" @click="selected">选择</el-button>
  34. <el-button size="small" @click="handleClose">关闭</el-button>
  35. </div>
  36. </el-dialog>
  37. </template>
  38. <script>
  39. import { getProduceTreeByCode } from '@/api/saleManage/quotation';
  40. import searchProduct from './searchProduct.vue';
  41. import { getInventoryTotalAPI } from '@/api/wms';
  42. import { getByCode } from '@/api/system/dictionary-data';
  43. import {
  44. businessStatus,
  45. networkStatus,
  46. treeClassifyCodeEnum
  47. } from '@/enum/dict';
  48. import { assetPageAPI } from '@/api/main';
  49. export default {
  50. components: {
  51. searchProduct
  52. },
  53. props: {
  54. code: {
  55. type: String,
  56. default: ''
  57. }
  58. },
  59. data() {
  60. return {
  61. visible: false,
  62. currentIndex: null,
  63. radio: null,
  64. dictList: {},
  65. selection: []
  66. };
  67. },
  68. watch: {},
  69. computed: {
  70. treeClassifyCodeEnum() {
  71. return treeClassifyCodeEnum;
  72. },
  73. columns() {
  74. return [
  75. {
  76. action: 'action',
  77. slot: 'action',
  78. align: 'center',
  79. label: '选择',
  80. show: this.currentIndex != -1
  81. },
  82. {
  83. label: '选择',
  84. show: this.currentIndex == -1,
  85. width: 45,
  86. type: 'selection',
  87. columnKey: 'selection',
  88. align: 'center'
  89. },
  90. {
  91. columnKey: 'index',
  92. type: 'index',
  93. label: '序号',
  94. width: 55,
  95. align: 'center',
  96. showOverflowTooltip: true,
  97. fixed: 'left'
  98. },
  99. {
  100. columnKey: 'code',
  101. prop: 'code',
  102. slot: 'code',
  103. label: '编码',
  104. showOverflowTooltip: true,
  105. minWidth: 180,
  106. align: 'center'
  107. },
  108. // {
  109. // columnKey: 'code',
  110. // prop: 'code',
  111. // label: '设备编码',
  112. // showOverflowTooltip: true,
  113. // minWidth: 110,
  114. // slot: 'code'
  115. // },
  116. {
  117. prop: 'name',
  118. label: '名称',
  119. showOverflowTooltip: true,
  120. minWidth: 110,
  121. align: 'center'
  122. },
  123. {
  124. prop: 'category.brandNum',
  125. label: '牌号',
  126. showOverflowTooltip: true,
  127. minWidth: 110,
  128. align: 'center'
  129. },
  130. {
  131. prop: 'fixCode',
  132. label: '固资编码',
  133. showOverflowTooltip: true,
  134. minWidth: 110,
  135. align: 'center'
  136. },
  137. {
  138. prop: 'postName',
  139. label: '使用岗位',
  140. showOverflowTooltip: true,
  141. minWidth: 110,
  142. align: 'center'
  143. },
  144. {
  145. prop: 'codeNumber',
  146. label: '编号',
  147. showOverflowTooltip: true,
  148. minWidth: 110,
  149. align: 'center'
  150. },
  151. {
  152. prop: 'category.modelType',
  153. label: '型号',
  154. showOverflowTooltip: true,
  155. minWidth: 110,
  156. align: 'center'
  157. },
  158. {
  159. prop: 'category.specification',
  160. label: '规格',
  161. showOverflowTooltip: true,
  162. minWidth: 110,
  163. align: 'center'
  164. },
  165. {
  166. prop: 'usePerson',
  167. label: '使用人',
  168. showOverflowTooltip: true,
  169. minWidth: 80,
  170. align: 'center'
  171. },
  172. {
  173. prop: 'chargePerson',
  174. label: '负责人',
  175. showOverflowTooltip: true,
  176. minWidth: 80,
  177. align: 'center'
  178. },
  179. {
  180. prop: 'endTime',
  181. label: '有效结束时间',
  182. showOverflowTooltip: true,
  183. minWidth: 150,
  184. align: 'center'
  185. },
  186. {
  187. prop: 'source',
  188. label: '生命周期',
  189. showOverflowTooltip: true,
  190. minWidth: 110,
  191. align: 'center'
  192. },
  193. {
  194. prop: 'level',
  195. label: '级别',
  196. showOverflowTooltip: true,
  197. minWidth: 110,
  198. formatter: (_row) => {
  199. return this.getDictV('asset_level', _row.level);
  200. },
  201. align: 'center'
  202. },
  203. {
  204. prop: 'networkStatus',
  205. label: '网络状态',
  206. showOverflowTooltip: true,
  207. minWidth: 110,
  208. formatter: (_row) => {
  209. if (_row.networkStatus) {
  210. return networkStatus.filter(
  211. (item) => item.code == _row.networkStatus
  212. )[0].label;
  213. } else {
  214. return '离线';
  215. }
  216. },
  217. align: 'center'
  218. },
  219. {
  220. prop: 'status',
  221. label: '状态',
  222. showOverflowTooltip: true,
  223. minWidth: 110,
  224. formatter: (_row) => {
  225. if (_row.status) {
  226. return businessStatus.filter(
  227. (item) => item.code == _row.status
  228. )[0].label;
  229. } else {
  230. return '空闲';
  231. }
  232. },
  233. align: 'center'
  234. },
  235. {
  236. prop: 'pathName',
  237. label: '位置',
  238. showOverflowTooltip: true,
  239. minWidth: 110,
  240. formatter: (_row) => {
  241. const positionDetail =
  242. _row.position &&
  243. _row.position.length != 0 &&
  244. _row.position[0].detailPosition
  245. ? _row.position[0].detailPosition
  246. : '-';
  247. return _row.deviceLocationName
  248. ? _row.deviceLocationName + '-' + positionDetail
  249. : '';
  250. },
  251. align: 'center'
  252. }
  253. ];
  254. }
  255. },
  256. methods: {
  257. getDictV(code, val) {
  258. if (!this.dictList[code]) return '';
  259. return this.dictList[code].find((item) => item.value == val)?.label;
  260. },
  261. async getDictList(code) {
  262. let { data: res } = await getByCode(code);
  263. this.dictList[code] = res.map((item) => {
  264. let values = Object.keys(item);
  265. return {
  266. value: values[0],
  267. label: item[values[0]]
  268. };
  269. });
  270. },
  271. async open(item, currentIndex) {
  272. this.currentIndex = currentIndex;
  273. this.visible = true;
  274. await this.getDictList('asset_level');
  275. },
  276. /* 表格数据源 */
  277. async datasource({ page, limit, where, order }) {
  278. let typeObj = await getProduceTreeByCode(this.code);
  279. return assetPageAPI({
  280. pageNum: page,
  281. size: limit,
  282. categoryLevelId: typeObj[0]?.id || '-1',
  283. ...where
  284. });
  285. },
  286. /* 刷新表格 */
  287. reload(where) {
  288. this.$refs.table.reload({ pageNum: 1, where: where });
  289. },
  290. handleNodeClick(data, node) {
  291. this.curNodeData = data;
  292. this.reload({ categoryLevelId: data.id });
  293. },
  294. // 单击获取id
  295. cellClick(row) {
  296. if (this.currentIndex == -1) return;
  297. this.current = row;
  298. this.radio = row.id;
  299. },
  300. handleClose() {
  301. this.visible = false;
  302. this.current = null;
  303. this.selection = [];
  304. this.$refs.table.clearSelection();
  305. this.radio = '';
  306. },
  307. async selected() {
  308. if (!this.current && !this.selection.length) {
  309. return this.$message.warning('请至少选择一条数据');
  310. }
  311. let list = this.currentIndex == -1 ? this.selection : [this.current];
  312. this.$emit('changeParent', list, this.currentIndex);
  313. this.handleClose();
  314. }
  315. }
  316. };
  317. </script>
  318. <style lang="scss" scoped>
  319. .tree_col {
  320. border: 1px solid #eee;
  321. padding: 10px 0;
  322. box-sizing: border-box;
  323. height: 500px;
  324. overflow: auto;
  325. }
  326. .table_col {
  327. padding-left: 10px;
  328. ::v-deep .el-table th.el-table__cell {
  329. background: #f2f2f2;
  330. }
  331. }
  332. .pagination {
  333. text-align: right;
  334. padding: 10px 0;
  335. }
  336. .btns {
  337. text-align: center;
  338. padding: 10px 0;
  339. }
  340. .topsearch {
  341. margin-bottom: 15px;
  342. }
  343. </style>