equipment-list.vue 8.7 KB

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