equipment-list.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <div>
  3. <equipment-search
  4. @search="reload"
  5. :networkCounts="networkCounts"
  6. ref="search"
  7. />
  8. <!-- 数据表格 -->
  9. <ele-pro-table
  10. ref="table"
  11. :columns="columns"
  12. :datasource="datasource"
  13. height="calc(100vh - 440px)"
  14. full-height="calc(100vh - 115px)"
  15. tool-class="ele-toolbar-form"
  16. cache-key="systemOrgUserTable"
  17. @row-click="handleView"
  18. @select="selectChange"
  19. @select-all="changeSelectAll"
  20. >
  21. <!-- 表头工具栏 -->
  22. <template v-slot:toolbar="{ row }">
  23. <!-- <el-button
  24. size="small"
  25. type="primary"
  26. icon="el-icon-plus"
  27. class="ele-btn-icon"
  28. @click="add"
  29. >
  30. 新建
  31. </el-button> -->
  32. <el-button
  33. size="small"
  34. icon="el-icon-download"
  35. class="ele-btn-icon"
  36. @click="exportFile"
  37. >
  38. 导出
  39. </el-button>
  40. <el-button
  41. size="small"
  42. :disabled="checkRadioData.length == 0"
  43. icon="el-icon-set-up"
  44. class="ele-btn-icon"
  45. >
  46. 打印条码
  47. </el-button>
  48. <el-button
  49. size="small"
  50. :disabled="checkRadioData.length == 0"
  51. icon="el-icon-thumb"
  52. class="ele-btn-icon"
  53. @click="moveTo(checkRadioData, 'person')"
  54. >
  55. 设置片区负责人
  56. </el-button>
  57. <el-button size="small" class="ele-btn-icon" @click="handlDelete"
  58. >删除</el-button
  59. >
  60. <el-button
  61. size="small"
  62. @click="moveTo(checkRadioData, 'move')"
  63. :disabled="checkRadioData.length == 0"
  64. class="ele-btn-icon"
  65. >移动到</el-button
  66. >
  67. </template>
  68. <!-- 编码列 -->
  69. <!-- <template v-slot:code="{ row }">
  70. <span>{{ row.code }}</span>
  71. </template> -->
  72. <!-- 操作列 -->
  73. <template v-slot:action="{ row }">
  74. <el-link
  75. type="primary"
  76. :underline="false"
  77. icon="el-icon-edit"
  78. @click="handEdit(row)"
  79. >
  80. 编辑
  81. </el-link>
  82. </template>
  83. </ele-pro-table>
  84. <DialogMoveto ref="movetoRef" @success="sucesstion" />
  85. </div>
  86. </template>
  87. <script>
  88. import EquipmentSearch from './equipment-search.vue';
  89. import DialogMoveto from './DialogMoveTo.vue';
  90. import {
  91. getAssetList,
  92. downloadAsset,
  93. getNetworkCount,
  94. batchDel
  95. } from '@/api/ledgerAssets';
  96. import dictMixins from '@/mixins/dictMixins';
  97. import axios from 'axios';
  98. import {
  99. API_BASE_URL,
  100. TOKEN_HEADER_NAME,
  101. LAYOUT_PATH
  102. } from '@/config/setting';
  103. import { download } from '@/utils/file';
  104. import { getToken, setToken } from '@/utils/token-util';
  105. export default {
  106. components: { EquipmentSearch, DialogMoveto },
  107. mixins: [dictMixins],
  108. props: {
  109. // 类别id
  110. categoryId: [Number, String],
  111. rootId: [Number, String],
  112. current: {
  113. typeof: Object,
  114. default: {}
  115. }
  116. },
  117. data() {
  118. return {
  119. // 表格列配置
  120. columns: [
  121. {
  122. width: 45,
  123. type: 'selection',
  124. columnKey: 'selection',
  125. align: 'center'
  126. },
  127. {
  128. columnKey: 'index',
  129. type: 'index',
  130. label: '序号',
  131. width: 55,
  132. align: 'center',
  133. showOverflowTooltip: true,
  134. fixed: 'left'
  135. },
  136. {
  137. columnKey: 'code',
  138. prop: 'code',
  139. label: '设备编码',
  140. showOverflowTooltip: true,
  141. minWidth: 130
  142. },
  143. // {
  144. // columnKey: 'code',
  145. // prop: 'code',
  146. // label: '设备编码',
  147. // showOverflowTooltip: true,
  148. // minWidth: 110,
  149. // slot: 'code'
  150. // },
  151. {
  152. prop: 'name',
  153. label: '设备名称',
  154. showOverflowTooltip: true,
  155. minWidth: 110
  156. },
  157. {
  158. prop: 'fixCode',
  159. label: '固资编码',
  160. showOverflowTooltip: true,
  161. minWidth: 110
  162. },
  163. {
  164. prop: 'postName',
  165. label: '使用岗位',
  166. showOverflowTooltip: true,
  167. minWidth: 110
  168. },
  169. {
  170. prop: 'codeNumber',
  171. label: '编号',
  172. showOverflowTooltip: true,
  173. minWidth: 110
  174. },
  175. // {
  176. // prop: 'codeNumber',
  177. // label: '编号',
  178. // showOverflowTooltip: true,
  179. // minWidth: 110
  180. // },
  181. {
  182. prop: 'category.modelType',
  183. label: '型号',
  184. showOverflowTooltip: true,
  185. minWidth: 110
  186. },
  187. {
  188. prop: 'category.specification',
  189. label: '规格',
  190. showOverflowTooltip: true,
  191. minWidth: 110
  192. },
  193. {
  194. prop: 'endTime',
  195. label: '有效期结束时间',
  196. showOverflowTooltip: true,
  197. minWidth: 150
  198. },
  199. {
  200. prop: 'source',
  201. label: '生命周期',
  202. showOverflowTooltip: true,
  203. minWidth: 110
  204. },
  205. {
  206. prop: 'networkStatus',
  207. label: '网络状态',
  208. showOverflowTooltip: true,
  209. minWidth: 110,
  210. formatter: (_row) =>
  211. this.getDictValue('网络状态', _row.networkStatus)
  212. },
  213. {
  214. prop: 'status',
  215. label: '状态',
  216. showOverflowTooltip: true,
  217. minWidth: 110
  218. },
  219. {
  220. prop: 'pathName',
  221. label: '位置',
  222. showOverflowTooltip: true,
  223. minWidth: 110,
  224. formatter: (_row) => {
  225. const positionDetail =
  226. _row.position.length != 0
  227. ? _row.position[0].detailPosition
  228. : '-';
  229. return _row.deviceLocationName + '-' + positionDetail;
  230. }
  231. },
  232. {
  233. columnKey: 'action',
  234. slot: 'action',
  235. label: '操作',
  236. minWidth: 100,
  237. fixed: 'right'
  238. }
  239. ],
  240. networkCounts: {},
  241. checkRadioData: []
  242. };
  243. },
  244. created() {
  245. this.requestDict('网络状态');
  246. },
  247. methods: {
  248. // 刷新回调
  249. sucesstion(is) {
  250. if (is) {
  251. this.reload();
  252. }
  253. this.checkRadioData = [];
  254. },
  255. // 移动到
  256. moveTo(arr, type) {
  257. this.$refs.movetoRef.open(arr, this.current, type);
  258. },
  259. // 全选
  260. changeSelectAll(arr) {
  261. console.log(arr);
  262. if (arr.length != 0) {
  263. this.checkRadioData = arr;
  264. } else {
  265. this.checkRadioData = [];
  266. }
  267. },
  268. selectChange(selection, row) {
  269. if (selection.length != 0) {
  270. this.checkRadioData = selection;
  271. } else {
  272. this.checkRadioData = [];
  273. }
  274. },
  275. handlDelete() {
  276. if (this.checkRadioData.length != 0) {
  277. this.$confirm('是否删除?', '提示', {
  278. confirmButtonText: '确定',
  279. cancelButtonText: '取消',
  280. type: 'warning'
  281. })
  282. .then(async () => {
  283. const paramsArr = this.checkRadioData.map((item) => {
  284. return item.id;
  285. });
  286. await batchDel(paramsArr);
  287. this.sucesstion(true);
  288. })
  289. .catch(() => {});
  290. }
  291. },
  292. /* 表格数据源 */
  293. datasource({ page, limit, where, order }) {
  294. this.getNetWork(page, limit, where, order);
  295. return getAssetList({
  296. ...where,
  297. ...order,
  298. pageNum: page,
  299. size: limit,
  300. categoryLevelId: this.categoryId,
  301. rootCategoryLevelId: this.rootId
  302. });
  303. },
  304. async getNetWork(page, limit, where, order) {
  305. const res = await getNetworkCount({
  306. ...where,
  307. ...order,
  308. pageNum: page,
  309. size: limit,
  310. categoryLevelId: this.categoryId,
  311. rootCategoryLevelId: this.rootId
  312. });
  313. this.networkCounts = res;
  314. },
  315. /* 刷新表格 */
  316. reload(where) {
  317. this.$refs.table.reload({ pageNum: 1, where: where });
  318. },
  319. // 跳转到详情页
  320. handleView({ id }) {
  321. this.$router.push({
  322. path: '/ledgerAssets/equipment/detail',
  323. query: {
  324. id
  325. }
  326. });
  327. },
  328. // 跳转到编辑
  329. handEdit({ id }) {
  330. this.$router.push({
  331. path: '/ledgerAssets/equipment/edit',
  332. query: {
  333. id
  334. }
  335. });
  336. },
  337. // 跳转到详情页
  338. add() {
  339. this.$router.push({
  340. path: '/ledgerAssets/equipment/edit'
  341. });
  342. },
  343. exportFile() {
  344. let params = {
  345. ...this.$refs.search.where,
  346. exportType: 1,
  347. categoryLevelId: this.categoryId,
  348. rootCategoryLevelId: this.rootId
  349. };
  350. // downloadAsset(params, '设备台账导出数据');
  351. axios({
  352. url: `${API_BASE_URL}/main/asset/page/export`,
  353. method: 'post',
  354. responseType: 'blob',
  355. headers: {
  356. Authorization: getToken()
  357. },
  358. data: params
  359. }).then((res) => {
  360. download(res.data, '设备台账导出数据');
  361. });
  362. }
  363. },
  364. watch: {
  365. // 监听类别id变化
  366. categoryId() {
  367. this.reload();
  368. }
  369. }
  370. };
  371. </script>