material-list.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div>
  3. <material-search
  4. @search="reload"
  5. :networkCounts="networkCounts"
  6. ref="searchRef"
  7. >
  8. </material-search>
  9. <!-- 数据表格 -->
  10. <ele-pro-table
  11. ref="table"
  12. :columns="columns"
  13. :datasource="datasource"
  14. height="calc(100vh - 440px)"
  15. full-height="calc(100vh - 115px)"
  16. tool-class="ele-toolbar-form"
  17. cache-key="systemOrgUserTable"
  18. >
  19. <!-- 表头工具栏 -->
  20. <template v-slot:toolbar>
  21. <el-button
  22. size="small"
  23. type="primary"
  24. icon="el-icon-plus"
  25. class="ele-btn-icon"
  26. @click="add"
  27. >
  28. 新建
  29. </el-button>
  30. <!-- <el-button
  31. size="small"
  32. type="primary"
  33. icon="el-icon-download"
  34. class="ele-btn-icon"
  35. @click="btnExport"
  36. >
  37. 导出
  38. </el-button> -->
  39. </template>
  40. <!-- 编码列 -->
  41. <template v-slot:code="{ row }">
  42. <el-link type="primary" :underline="false" @click="details(row)">
  43. {{ row.code }}
  44. </el-link>
  45. </template>
  46. <!-- 操作列 -->
  47. <template v-slot:action="{ row }">
  48. <el-link
  49. type="primary"
  50. :underline="false"
  51. icon="el-icon-edit"
  52. @click="goEdit(row)"
  53. >
  54. 编辑
  55. </el-link>
  56. </template>
  57. </ele-pro-table>
  58. </div>
  59. </template>
  60. <script>
  61. import { getByCode } from '@/api/system/dictionary-data';
  62. import { businessStatus, networkStatus } from '@/utils/dict/warehouse';
  63. import MaterialSearch from './material-search.vue';
  64. import {
  65. getBoatList,
  66. downloadCategory,
  67. getAssetList
  68. } from '@/api/ledgerAssets';
  69. export default {
  70. components: { MaterialSearch },
  71. props: {
  72. // 类别id
  73. categoryId: [Number, String],
  74. rootId: [Number, String]
  75. },
  76. data() {
  77. return {
  78. networkStatus,
  79. businessStatus,
  80. assetLevel: [],
  81. isConsumer: false,
  82. // 表格列配置
  83. columns: [
  84. {
  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. },
  107. // {
  108. // columnKey: 'code',
  109. // prop: 'code',
  110. // label: '设备编码',
  111. // showOverflowTooltip: true,
  112. // minWidth: 110,
  113. // slot: 'code'
  114. // },
  115. {
  116. prop: 'name',
  117. label: '名称',
  118. showOverflowTooltip: true,
  119. minWidth: 110
  120. },
  121. {
  122. prop: 'fixCode',
  123. label: '固资编码',
  124. showOverflowTooltip: true,
  125. minWidth: 110
  126. },
  127. {
  128. prop: 'postName',
  129. label: '使用岗位',
  130. showOverflowTooltip: true,
  131. minWidth: 110
  132. },
  133. {
  134. prop: 'codeNumber',
  135. label: '编号',
  136. showOverflowTooltip: true,
  137. minWidth: 110
  138. },
  139. // {
  140. // prop: 'codeNumber',
  141. // label: '编号',
  142. // showOverflowTooltip: true,
  143. // minWidth: 110
  144. // },
  145. {
  146. prop: 'category.modelType',
  147. label: '型号',
  148. showOverflowTooltip: true,
  149. minWidth: 110
  150. },
  151. {
  152. prop: 'category.specification',
  153. label: '规格',
  154. showOverflowTooltip: true,
  155. minWidth: 110
  156. },
  157. {
  158. prop: 'usePerson',
  159. label: '使用人',
  160. showOverflowTooltip: true,
  161. minWidth: 80
  162. },
  163. {
  164. prop: 'chargePerson',
  165. label: '负责人',
  166. showOverflowTooltip: true,
  167. minWidth: 80
  168. },
  169. {
  170. prop: 'endTime',
  171. label: '有效期结束时间',
  172. showOverflowTooltip: true,
  173. minWidth: 150
  174. },
  175. {
  176. prop: 'source',
  177. label: '生命周期',
  178. showOverflowTooltip: true,
  179. minWidth: 110
  180. },
  181. {
  182. prop: 'level',
  183. label: '级别',
  184. showOverflowTooltip: true,
  185. minWidth: 110,
  186. formatter: (_row) => {
  187. if (_row.level) {
  188. return this.assetLevel.filter(
  189. (item) => item.id == _row.level
  190. )[0].name;
  191. } else {
  192. return '';
  193. }
  194. }
  195. },
  196. {
  197. prop: 'networkStatus',
  198. label: '网络状态',
  199. showOverflowTooltip: true,
  200. minWidth: 110,
  201. formatter: (_row) => {
  202. console.log('_row.networkStatus-------', _row.networkStatus);
  203. if (_row.networkStatus) {
  204. return this.networkStatus.filter(
  205. (item) => item.code == _row.networkStatus
  206. )[0].label;
  207. } else {
  208. return '离线';
  209. }
  210. }
  211. },
  212. {
  213. prop: 'status',
  214. label: '状态',
  215. showOverflowTooltip: true,
  216. minWidth: 110,
  217. formatter: (_row) => {
  218. if (_row.status) {
  219. return this.businessStatus.filter(
  220. (item) => item.code == _row.status
  221. )[0].label;
  222. } else {
  223. return '空闲';
  224. }
  225. }
  226. },
  227. {
  228. prop: 'pathName',
  229. label: '位置',
  230. showOverflowTooltip: true,
  231. minWidth: 110,
  232. formatter: (_row) => {
  233. const positionDetail =
  234. _row.position &&
  235. _row.position.length != 0 &&
  236. _row.position[0].detailPosition
  237. ? _row.position[0].detailPosition
  238. : '-';
  239. return _row.deviceLocationName
  240. ? _row.deviceLocationName + '-' + positionDetail
  241. : '';
  242. }
  243. },
  244. {
  245. columnKey: 'action',
  246. slot: 'action',
  247. label: '操作',
  248. minWidth: 100,
  249. fixed: 'right'
  250. }
  251. ],
  252. networkCounts: {}
  253. };
  254. },
  255. created() {
  256. this.getAssetLevelOptions();
  257. },
  258. methods: {
  259. // 获取资产级别下拉
  260. async getAssetLevelOptions() {
  261. let { data } = await getByCode('asset_level');
  262. this.assetLevel =
  263. data.length > 0
  264. ? data.map((item) => {
  265. return {
  266. name: Object.keys(item)[0],
  267. id: item[Object.keys(item)[0]]
  268. };
  269. })
  270. : [];
  271. },
  272. // 跳转到详情页
  273. details({ id }) {
  274. this.$router.push({
  275. path: '/ledgerAssets/material/detail',
  276. query: {
  277. id
  278. }
  279. });
  280. },
  281. // 跳转到详情页
  282. add() {
  283. this.$router.push({
  284. path: '/ledgerAssets/material/edit'
  285. });
  286. },
  287. /* 表格数据源 */
  288. datasource({ page, limit, where, order }) {
  289. return getAssetList({
  290. ...where,
  291. ...order,
  292. pageNum: page,
  293. size: limit,
  294. categoryLevelId: this.categoryId,
  295. rootCategoryLevelId: this.rootId
  296. });
  297. },
  298. /* 刷新表格 */
  299. reload(where) {
  300. this.$refs.table.reload({ pageNum: 1, where: where });
  301. },
  302. // 跳转到详情页
  303. goEdit({ id }) {
  304. this.$router.push({
  305. path: '/ledgerAssets/material/edit',
  306. query: {
  307. id
  308. }
  309. });
  310. },
  311. // 导出
  312. btnExport() {
  313. let params = {
  314. ...this.$refs.searchRef.where,
  315. exportType: 2,
  316. categoryLevelId: this.categoryId,
  317. rootCategoryLevelId: this.rootId
  318. };
  319. downloadCategory(params, '原料台账导出数据');
  320. }
  321. },
  322. watch: {
  323. // 监听类别id变化
  324. rootId() {
  325. this.reload();
  326. }
  327. }
  328. };
  329. </script>